From b4524d343b085b63c68cf5e0a70007c19a048197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 23 Nov 2011 19:45:36 +0700 Subject: [PATCH 1/6] revert: do not pass non-literal string as format to git_path() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warning. CC builtin/revert.o builtin/revert.c: In function ‘write_cherry_pick_head’: builtin/revert.c:311: warning: format not a string literal and no format arguments Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/revert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/revert.c b/builtin/revert.c index 0c61668b85..9b9b2e5747 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -308,7 +308,7 @@ static void write_cherry_pick_head(struct commit *commit, const char *pseudoref) strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1)); - filename = git_path(pseudoref); + filename = git_path("%s", pseudoref); fd = open(filename, O_WRONLY | O_CREAT, 0666); if (fd < 0) die_errno(_("Could not open '%s' for writing"), filename); From 2a4037d0a745134a3b94cb3d60d2793a26bd9027 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 23 Nov 2011 09:49:38 +0100 Subject: [PATCH 2/6] Fix revert --abort on Windows On Windows, it is not possible to rename or remove a directory that has open files. 'revert --abort' renamed .git/sequencer when it still had .git/sequencer/head open. Close the file as early as possible to allow the rename operation on Windows. Signed-off-by: Johannes Sixt Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/revert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index 9b9b2e5747..c0b2592251 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -931,8 +931,10 @@ static int sequencer_rollback(struct replay_opts *opts) if (strbuf_getline(&buf, f, '\n')) { error(_("cannot read %s: %s"), filename, ferror(f) ? strerror(errno) : _("unexpected end of file")); + fclose(f); goto fail; } + fclose(f); if (get_sha1_hex(buf.buf, sha1) || buf.buf[40] != '\0') { error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"), filename); @@ -941,11 +943,9 @@ static int sequencer_rollback(struct replay_opts *opts) if (reset_for_rollback(sha1)) goto fail; strbuf_release(&buf); - fclose(f); return 0; fail: strbuf_release(&buf); - fclose(f); return -1; } From b15aa973b296ca36ae39592491bcb02944ac0f7a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 23 Nov 2011 04:04:52 -0600 Subject: [PATCH 3/6] revert --abort: do not leave behind useless sequencer-old directory The "git cherry-pick --abort" command currently renames the .git/sequencer directory to .git/sequencer-old instead of removing it on success due to an accident. cherry-pick --abort is designed to work in three steps: 1) find which commit to roll back to 2) call "git reset --merge " to move to that commit 3) remove the .git/sequencer directory But the careless author forgot step 3 entirely. The only reason the command worked anyway is that "git reset --merge " renames the .git/sequencer directory as a secondary effect --- after moving to , or so the logic goes, it is unlikely but possible that the caller of git reset wants to continue the series of cherry-picks that was in progress, so git renames the sequencer state to .git/sequencer-old to be helpful while allowing the cherry-pick to be resumed if the caller did not want to end the sequence after all. By running "git cherry-pick --abort", the operator has clearly indicated that she is not planning to continue cherry-picking. Remove the (renamed) .git/sequencer directory as intended all along. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/revert.c | 1 + t/t7106-reset-sequence.sh | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/builtin/revert.c b/builtin/revert.c index c0b2592251..1ea525c10e 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -942,6 +942,7 @@ static int sequencer_rollback(struct replay_opts *opts) } if (reset_for_rollback(sha1)) goto fail; + remove_sequencer_state(1); strbuf_release(&buf); return 0; fail: diff --git a/t/t7106-reset-sequence.sh b/t/t7106-reset-sequence.sh index 3f86e8c5e8..83f7ea59c9 100755 --- a/t/t7106-reset-sequence.sh +++ b/t/t7106-reset-sequence.sh @@ -41,4 +41,12 @@ test_expect_success 'reset --hard cleans up sequencer state, providing one-level test_path_is_missing .git/sequencer-old ' +test_expect_success 'cherry-pick --abort does not leave sequencer-old dir' ' + pristine_detach initial && + test_must_fail git cherry-pick base..anotherpick && + git cherry-pick --abort && + test_path_is_missing .git/sequencer && + test_path_is_missing .git/sequencer-old +' + test_done From 5cd75c7d8da8971d0d78f82d78c017e686fb5bb0 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 23 Nov 2011 07:31:55 +0100 Subject: [PATCH 4/6] builtin-branch: Fix crash on invalid use of --force The option --force should not put us in 'create branch' mode. The fact that this option is only valid in 'create branch' mode is already caught by the the next 'if' in which we assure that we are in the correct mode. Without this patch, "git branch -f" without any other argument ends up calling create_branch without any branch name. Signed-off-by: Vincent van Ravesteijn Signed-off-by: Junio C Hamano --- builtin/branch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index 51ca6a02d7..55cad766c7 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -705,7 +705,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, builtin_branch_usage, 0); - if (!delete && !rename && !force_create && argc == 0) + if (!delete && !rename && argc == 0) list = 1; if (!!delete + !!rename + !!force_create + !!list > 1) @@ -726,7 +726,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) rename_branch(argv[0], argv[1], rename > 1); else usage_with_options(builtin_branch_usage, options); - } else if (argc <= 2) { + } else if (argc > 0 && argc <= 2) { if (kinds != REF_LOCAL_BRANCH) die(_("-a and -r options to 'git branch' do not make sense with a branch name")); create_branch(head, argv[0], (argc == 2) ? argv[1] : head, From d69bafcb36e9a5920d7a848053f070562231a96d Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 23 Nov 2011 07:44:16 +0100 Subject: [PATCH 5/6] builtin-reset: Documentation update The second mode of 'git reset' is defined by the --patch option, while the third mode is defined by the option. Hence, these options are mandatory in the description of the individual modes. Signed-off-by: Vincent van Ravesteijn Signed-off-by: Junio C Hamano --- Documentation/git-reset.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index b2832fc7eb..b674866e6d 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -9,8 +9,8 @@ SYNOPSIS -------- [verse] 'git reset' [-q] [] [--] ... -'git reset' [--patch|-p] [] [--] [...] -'git reset' [--soft | --mixed | --hard | --merge | --keep] [-q] [] +'git reset' (--patch | -p) [] [--] [...] +'git reset' (--soft | --mixed | --hard | --merge | --keep) [-q] [] DESCRIPTION ----------- @@ -34,7 +34,7 @@ Alternatively, using linkgit:git-checkout[1] and specifying a commit, you can copy the contents of a path out of a commit to the index and to the working tree in one go. -'git reset' --patch|-p [] [--] [...]:: +'git reset' (--patch | -p) [] [--] [...]:: Interactively select hunks in the difference between the index and (defaults to HEAD). The chosen hunks are applied in reverse to the index. @@ -43,7 +43,7 @@ This means that `git reset -p` is the opposite of `git add -p`, i.e. you can use it to selectively reset hunks. See the ``Interactive Mode'' section of linkgit:git-add[1] to learn how to operate the `\--patch` mode. -'git reset' [--] []:: +'git reset' -- []:: This form resets the current branch head to and possibly updates the index (resetting it to the tree of ) and the working tree depending on , which From fc14b89a7e6899b8ac3b5751ec2d8c98203ea4c2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 28 Nov 2011 14:07:13 -0800 Subject: [PATCH 6/6] Git 1.7.8-rc4 Signed-off-by: Junio C Hamano --- Documentation/RelNotes/1.7.8.txt | 2 +- GIT-VERSION-GEN | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/RelNotes/1.7.8.txt b/Documentation/RelNotes/1.7.8.txt index d9da586972..95f5bffbe1 100644 --- a/Documentation/RelNotes/1.7.8.txt +++ b/Documentation/RelNotes/1.7.8.txt @@ -162,7 +162,7 @@ included in this release. --- exec >/var/tmp/1 -O=v1.7.8-rc3-16-g9e9ab40 +O=v1.7.8-rc4 echo O=$(git describe --always master) git log --first-parent --oneline --reverse ^$O master echo diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 6fbd7cd277..2d12904f60 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.7.8-rc3 +DEF_VER=v1.7.8-rc4 LF=' '