From 3f36cbbaaf87b67abafa851e2808735553f92b06 Mon Sep 17 00:00:00 2001 From: Carlos Rica Date: Wed, 9 Apr 2008 13:07:14 +0200 Subject: [PATCH 1/4] Fix documentation syntax of optional arguments in short options. When an argument for an option is optional, like in -n from git-tag, puting a space between the option and the argument is interpreted as a missing argument for the option plus an isolated argument. Documentation now reflects the need to write the parameter following the option -n, as in "git tag -nARG", for instance. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- Documentation/git-tag.txt | 4 ++-- builtin-tag.c | 2 +- parse-options.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index b62a3d1c58..74b461f661 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-tag' [-a | -s | -u ] [-f] [-m | -F ] [] 'git-tag' -d ... -'git-tag' [-n []] -l [] +'git-tag' [-n[]] -l [] 'git-tag' -v ... DESCRIPTION @@ -54,7 +54,7 @@ OPTIONS -v:: Verify the gpg signature of the given tag names. --n :: +-n:: specifies how many lines from the annotation, if any, are printed when using -l. The default is not to print any annotation lines. diff --git a/builtin-tag.c b/builtin-tag.c index 9a59caf70d..95ecfdbab6 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -16,7 +16,7 @@ static const char * const git_tag_usage[] = { "git-tag [-a|-s|-u ] [-f] [-m |-F ] []", "git-tag -d ...", - "git-tag -l [-n []] []", + "git-tag -l [-n[]] []", "git-tag -v ...", NULL }; diff --git a/parse-options.c b/parse-options.c index d9562ba504..59dc9ce6b4 100644 --- a/parse-options.c +++ b/parse-options.c @@ -330,7 +330,7 @@ void usage_with_options_internal(const char * const *usagestr, switch (opts->type) { case OPTION_INTEGER: if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " []"); + pos += fprintf(stderr, "[]"); else pos += fprintf(stderr, " "); break; From ac7fa2776c4a839a5a96c13886714774b52844de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 9 Apr 2008 23:14:43 +0200 Subject: [PATCH 2/4] git-archive: ignore prefix when checking file attribute Ulrik Sverdrup noticed that git-archive doesn't correctly apply the attribute export-subst when the option --prefix is given, too. When it checked if a file has the attribute turned on, git-archive would try to look up the full path -- including the prefix -- in .gitattributes. That's wrong, as the prefix doesn't need to have any relation to any existing directories, tracked or not. This patch makes git-archive ignore the prefix when looking up if value of the attribute export-subst for a file. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- archive-tar.c | 6 ++++-- archive-zip.c | 6 ++++-- t/t5000-tar-tree.sh | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/archive-tar.c b/archive-tar.c index 30aa2e23fd..4add80284e 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -17,6 +17,7 @@ static time_t archive_time; static int tar_umask = 002; static int verbose; static const struct commit *commit; +static size_t base_len; /* writes out the whole block, but only if it is full */ static void write_if_needed(void) @@ -251,8 +252,8 @@ static int write_tar_entry(const unsigned char *sha1, buffer = NULL; size = 0; } else { - buffer = sha1_file_to_archive(path.buf, sha1, mode, &type, - &size, commit); + buffer = sha1_file_to_archive(path.buf + base_len, sha1, mode, + &type, &size, commit); if (!buffer) die("cannot read %s", sha1_to_hex(sha1)); } @@ -272,6 +273,7 @@ int write_tar_archive(struct archiver_args *args) archive_time = args->time; verbose = args->verbose; commit = args->commit; + base_len = args->base ? strlen(args->base) : 0; if (args->commit_sha1) write_global_extended_header(args->commit_sha1); diff --git a/archive-zip.c b/archive-zip.c index 74e30f6205..18c0f8710c 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -13,6 +13,7 @@ static int verbose; static int zip_date; static int zip_time; static const struct commit *commit; +static size_t base_len; static unsigned char *zip_dir; static unsigned int zip_dir_size; @@ -197,8 +198,8 @@ static int write_zip_entry(const unsigned char *sha1, if (S_ISREG(mode) && zlib_compression_level != 0) method = 8; result = 0; - buffer = sha1_file_to_archive(path, sha1, mode, &type, &size, - commit); + buffer = sha1_file_to_archive(path + base_len, sha1, mode, + &type, &size, commit); if (!buffer) die("cannot read %s", sha1_to_hex(sha1)); crc = crc32(crc, buffer, size); @@ -321,6 +322,7 @@ int write_zip_archive(struct archiver_args *args) zip_dir_size = ZIP_DIRECTORY_MIN_SIZE; verbose = args->verbose; commit = args->commit; + base_len = args->base ? strlen(args->base) : 0; if (args->base && plen > 0 && args->base[plen - 1] == '/') { char *base = xstrdup(args->base); diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index dca2067b2d..fa62b6aa21 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -109,9 +109,10 @@ test_expect_success \ 'diff -r a c/prefix/a' test_expect_success \ - 'create an archive with a substfiles' \ + 'create archives with substfiles' \ 'echo "substfile?" export-subst >a/.gitattributes && git archive HEAD >f.tar && + git archive --prefix=prefix/ HEAD >g.tar && rm a/.gitattributes' test_expect_success \ @@ -126,6 +127,18 @@ test_expect_success \ diff a/substfile2 f/a/substfile2 ' +test_expect_success \ + 'extract substfiles from archive with prefix' \ + '(mkdir g && cd g && $TAR xf -) g/prefix/a/substfile1.expected && + diff g/prefix/a/substfile1.expected g/prefix/a/substfile1 && + diff a/substfile2 g/prefix/a/substfile2 +' + test_expect_success \ 'git archive --format=zip' \ 'git archive --format=zip HEAD >d.zip' From abea85d1e9ee0bd77e41e934534aa5d5cdd0593a Mon Sep 17 00:00:00 2001 From: Carlos Rica Date: Thu, 10 Apr 2008 02:08:23 +0200 Subject: [PATCH 3/4] core-tutorial.txt: Fix showing the current behaviour. The --root option from "git diff-tree" won't do nothing when is given to commands like git-whatchanged or git-log, because those always print the initial commit by default. This fixes the tutorial explaining the function of the log.showroot configuration variable. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- Documentation/core-tutorial.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt index aa40dfd36a..5a5531222d 100644 --- a/Documentation/core-tutorial.txt +++ b/Documentation/core-tutorial.txt @@ -535,18 +535,18 @@ with the associated patches use the more complex (and much more powerful) ---------------- -$ git-whatchanged -p --root +$ git-whatchanged -p ---------------- and you will see exactly what has changed in the repository over its short history. [NOTE] -The `\--root` flag is a flag to `git-diff-tree` to tell it to -show the initial aka 'root' commit too. Normally you'd probably not -want to see the initial import diff, but since the tutorial project -was started from scratch and is so small, we use it to make the result -a bit more interesting. +When using the above two commands, the initial commit will be shown. +If this is a problem because it is huge, you can hide it by setting +the log.showroot configuration variable to false. Having this, you +can still show it for each command just adding the `\--root` option, +which is a flag for `git-diff-tree` accepted by both commands. With that, you should now be having some inkling of what git does, and can explore on your own. From f59774add488a6c5fb440a4aaa7255f594b1027d Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 9 Apr 2008 20:03:49 -0400 Subject: [PATCH 4/4] git-fetch: fix status output when not storing tracking ref There was code in update_local_ref for handling this case, but it never actually got called. It assumed that storing in FETCH_HEAD meant a blank peer_ref name, but we actually have a NULL peer_ref in this case, so we never even made it to the update_local_ref function. On top of that, the display formatting was different from all of the other cases, probably owing to the fact that nobody had ever actually seen the output. This patch harmonizes the output with the other cases and moves the detection of this case into store_updated_refs, where we can actually trigger it. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-fetch.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/builtin-fetch.c b/builtin-fetch.c index 5841b3e51a..139a6b10c5 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -215,13 +215,6 @@ static int update_local_ref(struct ref *ref, if (type < 0) die("object %s not found", sha1_to_hex(ref->new_sha1)); - if (!*ref->name) { - /* Not storing */ - if (verbose) - sprintf(display, "* branch %s -> FETCH_HEAD", remote); - return 0; - } - if (!hashcmp(ref->old_sha1, ref->new_sha1)) { if (verbose) sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH, @@ -365,16 +358,21 @@ static int store_updated_refs(const char *url, struct ref *ref_map) rm->merge ? "" : "not-for-merge", note); - if (ref) { + if (ref) update_local_ref(ref, what, verbose, note); - if (*note) { - if (!shown_url) { - fprintf(stderr, "From %.*s\n", - url_len, url); - shown_url = 1; - } - fprintf(stderr, " %s\n", note); + else if (verbose) + sprintf(note, "* %-*s %-*s -> FETCH_HEAD", + SUMMARY_WIDTH, *kind ? kind : "branch", + REFCOL_WIDTH, *what ? what : "HEAD"); + else + *note = '\0'; + if (*note) { + if (!shown_url) { + fprintf(stderr, "From %.*s\n", + url_len, url); + shown_url = 1; } + fprintf(stderr, " %s\n", note); } } fclose(fp);