Merge branch 'master'
* master: Merge branch 'jc/ls-files-o' count-delta.c: Match the delta data semantics change in version 3. remove delta-against-self bit stat() for existence in safe_create_leading_directories() call git_config() after setup_git_directory() Add --diff-filter= documentation paragraph
This commit is contained in:
commit
3acfbd7cf8
@ -35,6 +35,17 @@
|
|||||||
-C::
|
-C::
|
||||||
Detect copies as well as renames.
|
Detect copies as well as renames.
|
||||||
|
|
||||||
|
--diff-filter=[ACDMRTUXB*]::
|
||||||
|
Select only files that are Added (`A`), Copied (`C`),
|
||||||
|
Deleted (`D`), Modified (`M`), Renamed (`R`), have their
|
||||||
|
type (mode) changed (`T`), are Unmerged (`U`), are
|
||||||
|
Unknown (`X`), or have had their pairing Broken (`B`).
|
||||||
|
Any combination of the filter characters may be used.
|
||||||
|
When `*` (All-or-none) is added to the combination, all
|
||||||
|
paths are selected if there is any file that matches
|
||||||
|
other criteria in the comparison; if there is no file
|
||||||
|
that matches other criteria, nothing is selected.
|
||||||
|
|
||||||
--find-copies-harder::
|
--find-copies-harder::
|
||||||
For performance reasons, by default, -C option finds copies only
|
For performance reasons, by default, -C option finds copies only
|
||||||
if the original file of the copy was modified in the same
|
if the original file of the copy was modified in the same
|
||||||
|
@ -86,13 +86,13 @@ int main(int argc, char **argv)
|
|||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|
||||||
setup_ident();
|
setup_ident();
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
git_config(git_default_config);
|
git_config(git_default_config);
|
||||||
|
|
||||||
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
|
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
|
||||||
usage(commit_tree_usage);
|
usage(commit_tree_usage);
|
||||||
|
|
||||||
setup_git_directory();
|
|
||||||
|
|
||||||
check_valid(tree_sha1, "tree");
|
check_valid(tree_sha1, "tree");
|
||||||
for (i = 2; i < argc; i += 2) {
|
for (i = 2; i < argc; i += 2) {
|
||||||
char *a, *b;
|
char *a, *b;
|
||||||
|
@ -50,12 +50,9 @@ int count_delta(void *delta_buf, unsigned long delta_size,
|
|||||||
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
||||||
if (cmd & 0x10) cp_size = *data++;
|
if (cmd & 0x10) cp_size = *data++;
|
||||||
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
||||||
|
if (cmd & 0x40) cp_size |= (*data++ << 16);
|
||||||
if (cp_size == 0) cp_size = 0x10000;
|
if (cp_size == 0) cp_size = 0x10000;
|
||||||
|
|
||||||
if (cmd & 0x40)
|
|
||||||
/* copy from dst */
|
|
||||||
;
|
|
||||||
else
|
|
||||||
copied_from_source += cp_size;
|
copied_from_source += cp_size;
|
||||||
out += cp_size;
|
out += cp_size;
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,9 +68,9 @@ static void parse_pack_header(void)
|
|||||||
hdr = (void *)pack_base;
|
hdr = (void *)pack_base;
|
||||||
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
||||||
die("packfile '%s' signature mismatch", pack_name);
|
die("packfile '%s' signature mismatch", pack_name);
|
||||||
if (hdr->hdr_version != htonl(PACK_VERSION))
|
if (!pack_version_ok(hdr->hdr_version))
|
||||||
die("packfile '%s' version %d different from ours %d",
|
die("packfile '%s' version %d unsupported",
|
||||||
pack_name, ntohl(hdr->hdr_version), PACK_VERSION);
|
pack_name, ntohl(hdr->hdr_version));
|
||||||
|
|
||||||
nr_objects = ntohl(hdr->hdr_entries);
|
nr_objects = ntohl(hdr->hdr_entries);
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ static int verify_packfile(struct packed_git *p)
|
|||||||
hdr = p->pack_base;
|
hdr = p->pack_base;
|
||||||
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
||||||
return error("Packfile %s signature mismatch", p->pack_name);
|
return error("Packfile %s signature mismatch", p->pack_name);
|
||||||
if (hdr->hdr_version != htonl(PACK_VERSION))
|
if (!pack_version_ok(hdr->hdr_version))
|
||||||
return error("Packfile version %d different from ours %d",
|
return error("Packfile version %d unsupported",
|
||||||
ntohl(hdr->hdr_version), PACK_VERSION);
|
ntohl(hdr->hdr_version));
|
||||||
nr_objects = ntohl(hdr->hdr_entries);
|
nr_objects = ntohl(hdr->hdr_entries);
|
||||||
if (num_packed_objects(p) != nr_objects)
|
if (num_packed_objects(p) != nr_objects)
|
||||||
return error("Packfile claims to have %d objects, "
|
return error("Packfile claims to have %d objects, "
|
||||||
|
1
pack.h
1
pack.h
@ -21,6 +21,7 @@ enum object_type {
|
|||||||
*/
|
*/
|
||||||
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
|
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
|
||||||
#define PACK_VERSION 2
|
#define PACK_VERSION 2
|
||||||
|
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
|
||||||
struct pack_header {
|
struct pack_header {
|
||||||
unsigned int hdr_signature;
|
unsigned int hdr_signature;
|
||||||
unsigned int hdr_version;
|
unsigned int hdr_version;
|
||||||
|
@ -44,16 +44,15 @@ void *patch_delta(void *src_buf, unsigned long src_size,
|
|||||||
cmd = *data++;
|
cmd = *data++;
|
||||||
if (cmd & 0x80) {
|
if (cmd & 0x80) {
|
||||||
unsigned long cp_off = 0, cp_size = 0;
|
unsigned long cp_off = 0, cp_size = 0;
|
||||||
const unsigned char *buf;
|
|
||||||
if (cmd & 0x01) cp_off = *data++;
|
if (cmd & 0x01) cp_off = *data++;
|
||||||
if (cmd & 0x02) cp_off |= (*data++ << 8);
|
if (cmd & 0x02) cp_off |= (*data++ << 8);
|
||||||
if (cmd & 0x04) cp_off |= (*data++ << 16);
|
if (cmd & 0x04) cp_off |= (*data++ << 16);
|
||||||
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
||||||
if (cmd & 0x10) cp_size = *data++;
|
if (cmd & 0x10) cp_size = *data++;
|
||||||
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
||||||
|
if (cmd & 0x40) cp_size |= (*data++ << 16);
|
||||||
if (cp_size == 0) cp_size = 0x10000;
|
if (cp_size == 0) cp_size = 0x10000;
|
||||||
buf = (cmd & 0x40) ? dst_buf : src_buf;
|
memcpy(out, src_buf + cp_off, cp_size);
|
||||||
memcpy(out, buf + cp_off, cp_size);
|
|
||||||
out += cp_size;
|
out += cp_size;
|
||||||
} else {
|
} else {
|
||||||
memcpy(out, data, cmd);
|
memcpy(out, data, cmd);
|
||||||
|
15
sha1_file.c
15
sha1_file.c
@ -6,8 +6,6 @@
|
|||||||
* This handles basic git sha1 object files - packing, unpacking,
|
* This handles basic git sha1 object files - packing, unpacking,
|
||||||
* creation etc.
|
* creation etc.
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "delta.h"
|
#include "delta.h"
|
||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
@ -74,6 +72,8 @@ int adjust_shared_perm(const char *path)
|
|||||||
int safe_create_leading_directories(char *path)
|
int safe_create_leading_directories(char *path)
|
||||||
{
|
{
|
||||||
char *pos = path;
|
char *pos = path;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if (*pos == '/')
|
if (*pos == '/')
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
@ -82,12 +82,17 @@ int safe_create_leading_directories(char *path)
|
|||||||
if (!pos)
|
if (!pos)
|
||||||
break;
|
break;
|
||||||
*pos = 0;
|
*pos = 0;
|
||||||
if (mkdir(path, 0777) < 0) {
|
if (!stat(path, &st)) {
|
||||||
if (errno != EEXIST) {
|
/* path exists */
|
||||||
|
if (!S_ISDIR(st.st_mode)) {
|
||||||
|
*pos = '/';
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mkdir(path, 0777)) {
|
||||||
*pos = '/';
|
*pos = '/';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (adjust_shared_perm(path)) {
|
else if (adjust_shared_perm(path)) {
|
||||||
*pos = '/';
|
*pos = '/';
|
||||||
return -2;
|
return -2;
|
||||||
|
@ -548,8 +548,8 @@ int main(int ac, char **av)
|
|||||||
int with_current_branch = 0;
|
int with_current_branch = 0;
|
||||||
int head_at = -1;
|
int head_at = -1;
|
||||||
|
|
||||||
git_config(git_show_branch_config);
|
|
||||||
setup_git_directory();
|
setup_git_directory();
|
||||||
|
git_config(git_show_branch_config);
|
||||||
|
|
||||||
/* If nothing is specified, try the default first */
|
/* If nothing is specified, try the default first */
|
||||||
if (ac == 1 && default_num) {
|
if (ac == 1 && default_num) {
|
||||||
|
@ -246,13 +246,12 @@ static void unpack_all(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct pack_header *hdr = fill(sizeof(struct pack_header));
|
struct pack_header *hdr = fill(sizeof(struct pack_header));
|
||||||
unsigned version = ntohl(hdr->hdr_version);
|
|
||||||
unsigned nr_objects = ntohl(hdr->hdr_entries);
|
unsigned nr_objects = ntohl(hdr->hdr_entries);
|
||||||
|
|
||||||
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
|
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
|
||||||
die("bad pack file");
|
die("bad pack file");
|
||||||
if (version != PACK_VERSION)
|
if (!pack_version_ok(hdr->hdr_version))
|
||||||
die("unable to handle pack file version %d", version);
|
die("unknown pack file version %d", ntohl(hdr->hdr_version));
|
||||||
fprintf(stderr, "Unpacking %d objects\n", nr_objects);
|
fprintf(stderr, "Unpacking %d objects\n", nr_objects);
|
||||||
|
|
||||||
use(sizeof(struct pack_header));
|
use(sizeof(struct pack_header));
|
||||||
|
Loading…
Reference in New Issue
Block a user