From eabbc99a2198d1cae62ce951457e7edc23b5f1a9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 5 Aug 2008 22:32:28 -0700 Subject: [PATCH 1/3] fix diff-tree --stdin documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Long time ago, the feature of "diff-tree --stdin" to take a commit and its parents on one line was broken, and did not support the common: git rev-list --parents $commits... -- $paths... | git diff-tree --stdin -v -p usage pattern by Porcelains properly. For diff-tree to talk sensibly about commits, it needs to see commits, not just trees; the code was fixed to take list of commits on the standard input in 1.2.0. However we left the documentation stale for a long time, until Karl Hasselström finally noticed it very recently. Signed-off-by: Junio C Hamano --- Documentation/git-diff-tree.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt index f4fbec48d8..5d23985b57 100644 --- a/Documentation/git-diff-tree.txt +++ b/Documentation/git-diff-tree.txt @@ -49,13 +49,13 @@ include::diff-options.txt[] --stdin:: When '--stdin' is specified, the command does not take arguments from the command line. Instead, it - reads either one or a pair of + reads either one or a list of separated with a single space from its standard input. + When a single commit is given on one line of such input, it compares the commit with its parents. The following flags further affects its -behavior. This does not apply to the case where two -separated with a single space are given. +behavior. The remaining commits, when given, are used as if they are +parents of the first commit. -m:: By default, "git-diff-tree --stdin" does not show From dbd0f5c7692cce0c5fea535a06622b3a93df9598 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 6 Aug 2008 11:43:47 -0700 Subject: [PATCH 2/3] Files given on the command line are relative to $cwd When running "git commit -F file" and "git tag -F file" from a subdirectory, we should take it as relative to the directory we started from, not relative to the top-level directory. This adds a helper function "parse_options_fix_filename()" to make it more convenient to fix this class of issues. Ideally, parse_options() should support a new type of option, "OPT_FILENAME", to do this uniformly, but this patch is meant to go to 'maint' to fix it minimally. One thing to note is that value for "commit template file" that comes from the command line is taken as relative to $cwd just like other parameters, but when it comes from the configuration varilable 'commit.template', it is taken as relative to the working tree root as before. I think this difference actually is sensible (not that I particularly think commit.template itself is sensible). Signed-off-by: Junio C Hamano --- builtin-commit.c | 11 +++++++---- builtin-tag.c | 3 ++- parse-options.c | 12 ++++++++++++ parse-options.h | 2 ++ t/t7004-tag.sh | 20 ++++++++++++++++++++ t/t7500-commit.sh | 29 +++++++++++++++++++++++++++++ 6 files changed, 72 insertions(+), 5 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index bcbea3893b..0c6d1f4f45 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -45,7 +45,7 @@ static enum { COMMIT_PARTIAL, } commit_style; -static char *logfile, *force_author; +static const char *logfile, *force_author; static const char *template_file; static char *edit_message, *use_message; static char *author_name, *author_email, *author_date; @@ -700,11 +700,14 @@ static int message_is_empty(struct strbuf *sb, int start) } static int parse_and_validate_options(int argc, const char *argv[], - const char * const usage[]) + const char * const usage[], + const char *prefix) { int f = 0; argc = parse_options(argc, argv, builtin_commit_options, usage, 0); + logfile = parse_options_fix_filename(prefix, logfile); + template_file = parse_options_fix_filename(prefix, template_file); if (logfile || message.len || use_message) use_editor = 0; @@ -814,7 +817,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) if (wt_status_use_color == -1) wt_status_use_color = git_use_color_default; - argc = parse_and_validate_options(argc, argv, builtin_status_usage); + argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix); index_file = prepare_index(argc, argv, prefix); @@ -907,7 +910,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) git_config(git_commit_config, NULL); - argc = parse_and_validate_options(argc, argv, builtin_commit_usage); + argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix); index_file = prepare_index(argc, argv, prefix); diff --git a/builtin-tag.c b/builtin-tag.c index 3c97c696a5..3bd019cc56 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -385,7 +385,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) int annotate = 0, sign = 0, force = 0, lines = 0, list = 0, delete = 0, verify = 0; - char *msgfile = NULL, *keyid = NULL; + const char *msgfile = NULL, *keyid = NULL; struct msg_arg msg = { 0, STRBUF_INIT }; struct option options[] = { OPT_BOOLEAN('l', NULL, &list, "list tag names"), @@ -411,6 +411,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) git_config(git_tag_config, NULL); argc = parse_options(argc, argv, options, git_tag_usage, 0); + msgfile = parse_options_fix_filename(prefix, msgfile); if (keyid) { sign = 1; diff --git a/parse-options.c b/parse-options.c index f8d52e21fe..12c882296e 100644 --- a/parse-options.c +++ b/parse-options.c @@ -425,3 +425,15 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg, *(unsigned long *)(opt->value) = approxidate(arg); return 0; } + +/* + * This should really be OPTION_FILENAME type as a part of + * parse_options that take prefix to do this while parsing. + */ +extern const char *parse_options_fix_filename(const char *prefix, const char *file) +{ + if (!file || !prefix || is_absolute_path(file) || !strcmp("-", file)) + return file; + return prefix_filename(prefix, strlen(prefix), file); +} + diff --git a/parse-options.h b/parse-options.h index 4ee443dafe..13ad15869e 100644 --- a/parse-options.h +++ b/parse-options.h @@ -123,4 +123,6 @@ extern int parse_opt_approxidate_cb(const struct option *, const char *, int); "use digits to display SHA-1s", \ PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 } +extern const char *parse_options_fix_filename(const char *prefix, const char *file); + #endif diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 241c70dc66..acddbf5037 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1067,4 +1067,24 @@ test_expect_success \ test_cmp expect actual ' +test_expect_success 'filename for the message is relative to cwd' ' + mkdir subdir && + echo "Tag message in top directory" >msgfile-5 && + echo "Tag message in sub directory" >subdir/msgfile-5 && + ( + cd subdir && + git tag -a -F msgfile-5 tag-from-subdir + ) && + git cat-file tag tag-from-subdir | grep "in sub directory" +' + +test_expect_success 'filename for the message is relative to cwd' ' + echo "Tag message in sub directory" >subdir/msgfile-6 && + ( + cd subdir && + git tag -a -F msgfile-6 tag-from-subdir-2 + ) && + git cat-file tag tag-from-subdir-2 | grep "in sub directory" +' + test_done diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh index baed6ce96b..823256a246 100755 --- a/t/t7500-commit.sh +++ b/t/t7500-commit.sh @@ -138,4 +138,33 @@ test_expect_success '--signoff' ' diff expect output ' +test_expect_success 'commit message from file (1)' ' + mkdir subdir && + echo "Log in top directory" >log && + echo "Log in sub directory" >subdir/log && + ( + cd subdir && + git commit --allow-empty -F log + ) && + commit_msg_is "Log in sub directory" +' + +test_expect_success 'commit message from file (2)' ' + rm -f log && + echo "Log in sub directory" >subdir/log && + ( + cd subdir && + git commit --allow-empty -F log + ) && + commit_msg_is "Log in sub directory" +' + +test_expect_success 'commit message from stdin' ' + ( + cd subdir && + echo "Log with foo word" | git commit --allow-empty -F - + ) && + commit_msg_is "Log with foo word" +' + test_done From 781c1834f5419bdf81bb7f3750170ccd6b809174 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 6 Aug 2008 12:04:06 -0700 Subject: [PATCH 3/3] GIT 1.5.6.5 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.5.6.5.txt | 9 +++------ Documentation/git.txt | 10 ++++++---- GIT-VERSION-GEN | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Documentation/RelNotes-1.5.6.5.txt b/Documentation/RelNotes-1.5.6.5.txt index 23981acf39..47ca172462 100644 --- a/Documentation/RelNotes-1.5.6.5.txt +++ b/Documentation/RelNotes-1.5.6.5.txt @@ -6,6 +6,9 @@ Fixes since v1.5.6.4 * "git cvsimport" used to spit out "UNKNOWN LINE..." diagnostics to stdout. +* "git commit -F filename" and "git tag -F filename" run from subdirectories + did not read the right file. + * "git init --template=" with blank "template" parameter linked files under root directories to .git, which was a total nonsense. Instead, it means "I do not want to use anything from the template directory". @@ -24,9 +27,3 @@ Fixes since v1.5.6.4 header properly. Contains other various documentation fixes. - --- -exec >/var/tmp/1 -echo O=$(git describe maint) -O=v1.5.6.4-26-g2b6ca6d -git shortlog --no-merges $O..maint diff --git a/Documentation/git.txt b/Documentation/git.txt index 33ae79b9d5..0f55f8005b 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,12 +43,14 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.5.6.3/git.html[documentation for release 1.5.6.3] +* link:v1.5.6.5/git.html[documentation for release 1.5.6.5] * release notes for - link:RelNotes-1.5.6.3.txt[1.5.6.3]. - link:RelNotes-1.5.6.2.txt[1.5.6.2]. - link:RelNotes-1.5.6.1.txt[1.5.6.1]. + link:RelNotes-1.5.6.5.txt[1.5.6.5], + link:RelNotes-1.5.6.4.txt[1.5.6.4], + link:RelNotes-1.5.6.3.txt[1.5.6.3], + link:RelNotes-1.5.6.2.txt[1.5.6.2], + link:RelNotes-1.5.6.1.txt[1.5.6.1], link:RelNotes-1.5.6.txt[1.5.6]. * link:v1.5.5.4/git.html[documentation for release 1.5.5.4] diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index f221447478..445dca3ffc 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.5.6.GIT +DEF_VER=v1.5.6.5.GIT LF=' '