Re: Measuring Community Involvement (was Re: Contributor Summit planning)
Jeff King wrote: > On Tue, Aug 14, 2018 at 12:47:59PM -0700, Stefan Beller wrote: > > With the advent of public inbox, this is easy to obtain? > > For our project, yes. But I was thinking of a tool that could be used > for other projects, too. Nothing prevents public-inbox from being adopted by other projects :) Fwiw, Linux Foundation has LKML at https://lore.kernel.org/lkml
Re: [PATCH 1/2] store submodule in common dir
On Tue, 2018-08-14 at 16:20 -0700, Junio C Hamano wrote: > CAUTION: This email originated from outside of the organization. Do not click > links or open attachments unless you recognize the sender and know the > content is safe. > > > Junio C Hamano writes: > > > My understanding of what Joakim wants to do is to have a top-level > > project that has three subdirectories, e.g. kernel/v2.2, kernel/v2.4 > > and kernel/v2.6, each of which is a submodule that houses these > > versions of Linux kernel source, but only clone Linus's repository > > (as the up-to-late tree has all the necessary history to check out > > these past development tracks). And that should be doable with > > just the main checkout, without any additional worktree (it's just > > the matter of having .git/modules/kernel%2fv2.6/ directory pointed > > by two symlinks from .git/modules/kernel%2fv2.[24], or something > > like that). > > Actually I take the last part of that back. When thought naively > about, it may appear that it should be doable, but because each of > the modules/* directory in the top-level project has to serve as the > $GIT_DIR for each submodule checkout, and the desire is to have > these three directories to have checkout of three different > branches, a single directory under modules/. that is shared among > three submodules would *not* work---they must have separate index, > HEAD, etc. > > Theoretically we should be able to make modules/kernel%2fv2.[24] > additional "worktree"s of modules/kernel%2fv2.6, but given that > these are all "bare" repositories without an attached working tree, > I am not sure how that would supposed to work. Thinking about > having multiple worktrees on a single bare repository makes me head > spin and ache X-<;-) You nailed it ! :) My head spins just reading this so I think I got my answer. I can be done but will be tricky to impl. I will keep an eye on how submodules develops, sure would be a welcome feature. Jocke
Re: [PATCH 1/2] store submodule in common dir
On Wed, 2018-08-15 at 10:28 +0200, Joakim Tjernlund wrote: > On Tue, 2018-08-14 at 16:20 -0700, Junio C Hamano wrote: > > CAUTION: This email originated from outside of the organization. Do not > > click links or open attachments unless you recognize the sender and know > > the content is safe. > > > > > > Junio C Hamano writes: > > > > > My understanding of what Joakim wants to do is to have a top-level > > > project that has three subdirectories, e.g. kernel/v2.2, kernel/v2.4 > > > and kernel/v2.6, each of which is a submodule that houses these > > > versions of Linux kernel source, but only clone Linus's repository > > > (as the up-to-late tree has all the necessary history to check out > > > these past development tracks). And that should be doable with > > > just the main checkout, without any additional worktree (it's just > > > the matter of having .git/modules/kernel%2fv2.6/ directory pointed > > > by two symlinks from .git/modules/kernel%2fv2.[24], or something > > > like that). > > > > Actually I take the last part of that back. When thought naively > > about, it may appear that it should be doable, but because each of > > the modules/* directory in the top-level project has to serve as the > > $GIT_DIR for each submodule checkout, and the desire is to have > > these three directories to have checkout of three different > > branches, a single directory under modules/. that is shared among > > three submodules would *not* work---they must have separate index, > > HEAD, etc. > > > > Theoretically we should be able to make modules/kernel%2fv2.[24] > > additional "worktree"s of modules/kernel%2fv2.6, but given that > > these are all "bare" repositories without an attached working tree, > > I am not sure how that would supposed to work. Thinking about > > having multiple worktrees on a single bare repository makes me head > > spin and ache X-<;-) > > You nailed it ! :) > My head spins just reading this so I think I got my answer. I can be done > but will be tricky to impl. > I will keep an eye on how submodules develops, sure would be a welcome > feature. > > Jocke On a related note, it would be great if git could support sparse checkout/clone for submodules, now one have to manually add .git/info/sparse-checkout. If sparse clone and sparse checkout could be saved in the submodule, then there would be no problem with 3 copies of the same repo in my submodules. Jocke
[PATCH 2/2] rebase -i: fix SIGSEGV when 'merge ' fails
From: Phillip Wood If a merge command in the todo list specifies just a branch to merge with no -C/-c argument then item->commit is NULL. This means that if there are merge conflicts error_with_patch() is passed a NULL commit which causes a segmentation fault when make_patch() tries to look it up. This commit implements a minimal fix which fixes the crash and allows the user to successfully commit a conflict resolution with 'git rebase --continue'. It does not write .git/rebase-merge/patch, .git/rebase-merge/stopped-sha or update REBASE_HEAD. To sensibly get the hashes of the merge parents would require refactoring do_merge() to extract the code that parses the merge parents into a separate function which error_with_patch() could then use to write the parents into the stopped-sha file. To create meaningful output make_patch() and 'git rebase --show-current-patch' would also need to be modified to diff the merge parent and merge base in this case. Signed-off-by: Phillip Wood --- sequencer.c | 24 +++- t/t3430-rebase-merges.sh | 15 ++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/sequencer.c b/sequencer.c index 4034c0461b..df49199175 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2590,8 +2590,12 @@ static int error_with_patch(struct commit *commit, const char *subject, int subject_len, struct replay_opts *opts, int exit_code, int to_amend) { - if (make_patch(commit, opts)) - return -1; + if (commit) { + if (make_patch(commit, opts)) + return -1; + } else if (copy_file(rebase_path_message(), git_path_merge_msg(), 0666)) + return error(_("unable to copy '%s' to '%s'"), +git_path_merge_msg(), rebase_path_message()); if (to_amend) { if (intend_to_amend()) @@ -2604,9 +2608,19 @@ static int error_with_patch(struct commit *commit, "Once you are satisfied with your changes, run\n" "\n" " git rebase --continue\n", gpg_sign_opt_quoted(opts)); - } else if (exit_code) - fprintf(stderr, "Could not apply %s... %.*s\n", - short_commit_name(commit), subject_len, subject); + } else if (exit_code) { + if (commit) + fprintf(stderr, "Could not apply %s... %.*s\n", + short_commit_name(commit), + subject_len, subject); + else + /* +* We don't have the hash of the parent so +* just print the line from the todo file. +*/ + fprintf(stderr, "Could not merge %.*s\n", + subject_len, subject); + } return exit_code; } diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 31fe4268d5..2e767d4f1e 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -129,7 +129,7 @@ test_expect_success '`reset` refuses to overwrite untracked files' ' git rebase --abort ' -test_expect_success 'failed `merge` writes patch (may be rescheduled, too)' ' +test_expect_success 'failed `merge -C` writes patch (may be rescheduled, too)' ' test_when_finished "test_might_fail git rebase --abort" && git checkout -b conflicting-merge A && @@ -151,6 +151,19 @@ test_expect_success 'failed `merge` writes patch (may be rescheduled, too)' ' test_path_is_file .git/rebase-merge/patch ' +SQ="'" +test_expect_success 'failed `merge ` does not crash' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout conflicting-G && + + echo "merge G" >script-from-scratch && + test_config sequence.editor \""$PWD"/replace-editor.sh\" && + test_tick && + test_must_fail git rebase -ir HEAD && + ! grep "^merge G$" .git/rebase-merge/git-rebase-todo && + grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message +' + test_expect_success 'with a branch tip that was cherry-picked already' ' git checkout -b already-upstream master && base="$(git rev-parse --verify HEAD)" && -- 2.18.0
[PATCH 0/2] rebase -i: fix SIGSEGV when 'merge ' fails
From: Phillip Wood As they fix a bug these patches are based on maint. Unfortunately the second patch has semantic conflicts with master s/git_path_merge_msg()/git_path_merge_msg(the_repository)/ There are additional textual conflicts with pu/next due to some messages being marked for translation. The new message here should be marked for translation to match them. Phillip Wood (2): t3430: add conflicting commit rebase -i: fix SIGSEGV when 'merge ' fails sequencer.c | 24 +++- t/t3430-rebase-merges.sh | 30 +++--- 2 files changed, 42 insertions(+), 12 deletions(-) -- 2.18.0
[PATCH 1/2] t3430: add conflicting commit
From: Phillip Wood Move the creation of conflicting-G from a test to the setup so that it can be used in subsequent tests without creating the kind of implicit dependencies that plague t3404. While we're at it simplify the arguments to the test_commit() call the creates the conflicting commit. Signed-off-by: Phillip Wood --- t/t3430-rebase-merges.sh | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 78f7c99580..31fe4268d5 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -13,8 +13,10 @@ Initial setup: -- B -- (first) / \ A - C - D - E - H(master) - \ / - F - G(second) + \\ / +\F - G(second) + \ + Conflicting-G ' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -49,7 +51,9 @@ test_expect_success 'setup' ' git merge --no-commit G && test_tick && git commit -m H && - git tag -m H H + git tag -m H H && + git checkout A && + test_commit conflicting-G G.t ' test_expect_success 'create completely different structure' ' @@ -72,7 +76,7 @@ test_expect_success 'create completely different structure' ' EOF test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && - git rebase -i -r A && + git rebase -i -r A master && test_cmp_graph <<-\EOF * Merge the topic branch '\''onebranch'\'' |\ @@ -141,8 +145,7 @@ test_expect_success 'failed `merge` writes patch (may be rescheduled, too)' ' : fail because of merge conflict && rm G.t .git/rebase-merge/patch && - git reset --hard && - test_commit conflicting-G G.t not-G conflicting-G && + git reset --hard conflicting-G && test_must_fail git rebase --continue && ! grep "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && test_path_is_file .git/rebase-merge/patch -- 2.18.0
[PATCH] rebase -i: fix numbering in squash message
From: Phillip Wood Commit e12a7ef597 ("rebase -i: Handle "combination of commits" with GETTEXT_POISON", 2018-04-27) changed the way that individual commit messages are labelled when squashing commits together. In doing so a regression was introduced where the numbering of the messages is off by one. This commit fixes that and adds a test for the numbering. Signed-off-by: Phillip Wood --- sequencer.c| 4 ++-- t/t3418-rebase-continue.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sequencer.c b/sequencer.c index 2eb5ec7227..77d3c2346f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1387,13 +1387,13 @@ static int update_squash_messages(enum todo_command command, unlink(rebase_path_fixup_msg()); strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _("This is the commit message #%d:"), - ++opts->current_fixup_count); + ++opts->current_fixup_count + 1); strbuf_addstr(&buf, "\n\n"); strbuf_addstr(&buf, body); } else if (command == TODO_FIXUP) { strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _("The commit message #%d will be skipped:"), - ++opts->current_fixup_count); + ++opts->current_fixup_count + 1); strbuf_addstr(&buf, "\n\n"); strbuf_add_commented_lines(&buf, body, strlen(body)); } else diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index e9fd029160..ee871dd1bb 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -128,13 +128,15 @@ test_expect_success '--skip after failed fixup cleans commit message' ' : The first squash was skipped, therefore: && git show HEAD >out && test_i18ngrep "# This is a combination of 2 commits" out && + test_i18ngrep "# This is the commit message #2:" out && (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) && git show HEAD >out && test_i18ngrep ! "# This is a combination" out && : Final squash failed, but there was still a squash && - test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt + test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt && + test_i18ngrep "# This is the commit message #2:" .git/copy.txt ' test_expect_success 'setup rerere database' ' -- 2.18.0
[PATCH] branch: support configuring --sort via .gitconfig
From: Samuel Maftoul Add support for configuring default sort ordering for git branches. Command line option will override this configured value, using the exact same syntax. --- Documentation/config.txt | 5 + Documentation/git-branch.txt | 4 builtin/branch.c | 10 +- t/t3200-branch.sh| 46 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 63365dcf3..82e306d20 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1034,6 +1034,11 @@ branch.autoSetupRebase:: branch to track another branch. This option defaults to never. +branch.sort:: + This variable controls the sort ordering of branches when displayed by + linkgit:git-branch[1]. Without the "--sort=" option provided, the + value of this variable will be used as the default. + branch..remote:: When on branch , it tells 'git fetch' and 'git push' which remote to fetch from/push to. The remote to push to diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 1072ca0eb..9212a8d5d 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -272,6 +272,10 @@ start-point is either a local or remote-tracking branch. full refname (including `refs/...` prefix). This lists detached HEAD (if present) first, then local branches and finally remote-tracking branches. + The keys supported are the same as those in `git for-each-ref`. + Sort order defaults to the value configured for the `tag.sort` + variable if it exists, or lexicographic order otherwise. See + linkgit:git-config[1]. --points-at :: diff --git a/builtin/branch.c b/builtin/branch.c index 4fc55c350..bbd006aab 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -74,6 +74,14 @@ define_list_config_array(color_branch_slots); static int git_branch_config(const char *var, const char *value, void *cb) { const char *slot_name; + struct ref_sorting **sorting_tail = (struct ref_sorting **)cb; + + if (!strcmp(var, "branch.sort")) { + if (!value) + return config_error_nonbool(var); + parse_ref_sorting(sorting_tail, value); + return 0; + } if (starts_with(var, "column.")) return git_column_config(var, value, "branch", &colopts); @@ -653,7 +661,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_branch_usage, options); - git_config(git_branch_config, NULL); + git_config(git_branch_config, sorting_tail); track = git_branch_track; diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index dbca665da..8bd42e9c6 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -1305,4 +1305,50 @@ test_expect_success 'tracking with unexpected .fetch refspec' ' ) ' +test_expect_success 'configured committerdate sort' ' + git init sort && + ( + cd sort && + git config branch.sort committerdate && + test_commit initial && + git checkout -b a && + test_commit a && + git checkout -b c && + test_commit c && + git checkout -b b && + test_commit b && + git branch >actual && + cat >expect <<-\EOF && + master + a + c + * b + EOF + test_cmp expect actual + ) +' + +test_expect_success 'option override configured sort' ' + ( + cd sort && + git branch --sort=refname >actual && + cat >expect <<-\EOF && + a + * b + c + master + EOF + test_cmp expect actual + ) +' + +test_expect_success 'invalid sort parameter in configuration' ' + ( + cd sort && + git config branch.sort "v:notvalid" && + test_must_fail git branch + + ) +' + test_done -- 2.14.3 (Apple Git-98)
Re: [PATCH 4/7] for_each_packed_object: support iterating in pack-order
On 8/10/2018 7:15 PM, Jeff King wrote: diff --git a/commit-graph.c b/commit-graph.c index b0a55ad128..69a0d1c203 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -730,7 +730,7 @@ void write_commit_graph(const char *obj_dir, die("error adding pack %s", packname.buf); if (open_pack_index(p)) die("error opening index for %s", packname.buf); - for_each_object_in_pack(p, add_packed_commits, &oids); + for_each_object_in_pack(p, add_packed_commits, &oids, 0); close_pack(p); } This use in write_commit_graph() is actually a good candidate for pack-order, since we are checking each object to see if it is a commit. This is only used when running `git commit-graph write --stdin-packs`, which is how VFS for Git maintains the commit-graph. I have a note to run performance tests on this case and follow up with a change on top of this series that adds the FOR_EACH_OBJECT_PACK_ORDER flag. Thanks, -Stolee
Re: [PATCH 0/7] speeding up cat-file by reordering object access
On 8/10/2018 7:07 PM, Jeff King wrote: The general idea is that accessing objects in packfile order is way kinder to the delta base cache, and thus way more efficient. See patches 4 and 7 in particular for discussion and numbers. I'm primarily interested in cat-file, so this series is focused there. But there may be other callers of for_each_packed_object() who could benefit. Most of the existing ones just care about getting the oid, so they're better off as-is. It's possible the call in is_promisor_object() could benefit, since it calls parse_object() on each entry it visits. I didn't experiment with it. I like this series, and the follow-up. I could not find any problems with it. One thing that I realized while reading it is that the multi-pack-index is not integrated into the for_each_packed_object method. I was already going to work on some cleanups in that area [1][2]. When using the new flag with the multi-pack-index, I expect that we will want to load the pack-files that are covered by the multi-pack-index (simply, the 'packs' array) and use the same mechanism to traverse them in order. The only "strange" thing about this is that we would see duplicate objects when traversing the pack-files directly but not when traversing the multi-pack-index (since it de-duplicates when indexing). I hope to have a series working on top of this series by end-of-week. Thanks, -Stolee [1] https://public-inbox.org/git/CAPig+cTU--KrGcv4C_CwBZEuec4dgm_tJqL=cfwkt6vxxr0...@mail.gmail.com/ Re: [PATCH v4 04/23] multi-pack-index: add 'write' verb (Recommends more user-friendly usage reporting in 'git multi-pack-index') [2] https://public-inbox.org/git/20180814222846.gg142...@aiede.svl.corp.google.com/ [PATCH] partial-clone: render design doc using asciidoc (The commit-graph and multi-pack-index docs are not in the Makefile, either.)
[PATCH 0/1] Fix make -C t chainlint with DOS line endings
Historically, nobody paid attention to our own source code having correct Git attributes [https://www.edwardthomson.com/blog/git_for_windows_line_endings.html] when it comes to line endings. Because historically, we had no good way to specify that ;-) But now we do, and so we need to use it. Especially when it would break the build otherwise. Johannes Schindelin (1): chainlint: fix for core.autocrlf=true t/.gitattributes | 1 + 1 file changed, 1 insertion(+) base-commit: 1d89318c48d233d52f1db230cf622935ac3c69fa Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-19%2Fdscho%2Ffix-chainlint-on-windows-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-19/dscho/fix-chainlint-on-windows-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/19 -- gitgitgadget
[PATCH 1/1] chainlint: fix for core.autocrlf=true
From: Johannes Schindelin The `chainlint` target compares actual output to expected output, where the actual output is generated from files that are specifically checked out with LF-only line endings. So the expected output needs to be checked out with LF-only line endings, too. Signed-off-by: Johannes Schindelin --- t/.gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/t/.gitattributes b/t/.gitattributes index 3bd959ae5..9d09df5a6 100644 --- a/t/.gitattributes +++ b/t/.gitattributes @@ -1,4 +1,5 @@ t[0-9][0-9][0-9][0-9]/* -whitespace +/chainlint/*.expect eol=lf /diff-lib/* eol=lf /t0110/url-* binary /t3900/*.txt eol=lf -- gitgitgadget
[PATCH] Makefile: extend NO_TCLTK=NoThanks to cover docs
Extend the NO_TCLTK=NoThanks flag to be understood by the Documentation Makefile. Before this change compiling and installing with NO_TCLTK would result in no git-gui, gitk or git-citool being installed, but their respective manual pages would still be installed. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/Makefile | 23 ++- Makefile | 39 +-- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index d079d7c73a..d53979939e 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,5 +1,7 @@ # Guard against environment variables MAN1_TXT = +MAN1_TXT_WIP = +TCLTK_FILES = MAN5_TXT = MAN7_TXT = TECH_DOCS = @@ -7,13 +9,24 @@ ARTICLES = SP_ARTICLES = OBSOLETE_HTML = -MAN1_TXT += $(filter-out \ +MAN1_TXT_WIP += $(filter-out \ $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ $(wildcard git-*.txt)) -MAN1_TXT += git.txt -MAN1_TXT += gitk.txt -MAN1_TXT += gitremote-helpers.txt -MAN1_TXT += gitweb.txt +MAN1_TXT_WIP += git.txt +MAN1_TXT_WIP += gitremote-helpers.txt +MAN1_TXT_WIP += gitweb.txt + +ifndef NO_TCLTK +MAN1_TXT_WIP += gitk.txt +MAN1_TXT = $(MAN1_TXT_WIP) +else +TCLTK_FILES += git-gui.txt +TCLTK_FILES += gitk.txt +TCLTK_FILES += git-citool.txt +MAN1_TXT = $(filter-out \ + $(TCLTK_FILES), \ + $(MAN1_TXT_WIP)) +endif MAN5_TXT += gitattributes.txt MAN5_TXT += githooks.txt diff --git a/Makefile b/Makefile index bc4fc8eeab..8abb23f6ce 100644 --- a/Makefile +++ b/Makefile @@ -2372,21 +2372,21 @@ export DEFAULT_EDITOR DEFAULT_PAGER .PHONY: doc man man-perl html info pdf doc: man-perl - $(MAKE) -C Documentation all + $(MAKE) -C Documentation all NO_TCLTK='$(NO_TCLTK)' man: man-perl - $(MAKE) -C Documentation man + $(MAKE) -C Documentation man NO_TCLTK='$(NO_TCLTK)' man-perl: perl/build/man/man3/Git.3pm html: - $(MAKE) -C Documentation html + $(MAKE) -C Documentation html NO_TCLTK='$(NO_TCLTK)' info: - $(MAKE) -C Documentation info + $(MAKE) -C Documentation info NO_TCLTK='$(NO_TCLTK)' pdf: - $(MAKE) -C Documentation pdf + $(MAKE) -C Documentation pdf NO_TCLTK='$(NO_TCLTK)' XGETTEXT_FLAGS = \ --force-po \ @@ -2802,10 +2802,10 @@ install-gitweb: $(MAKE) -C gitweb install install-doc: install-man-perl - $(MAKE) -C Documentation install + $(MAKE) -C Documentation install NO_TCLTK='$(NO_TCLTK)' install-man: install-man-perl - $(MAKE) -C Documentation install-man + $(MAKE) -C Documentation install-man NO_TCLTK='$(NO_TCLTK)' install-man-perl: man-perl $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3' @@ -2813,22 +2813,22 @@ install-man-perl: man-perl (cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR) xof -) install-html: - $(MAKE) -C Documentation install-html + $(MAKE) -C Documentation install-html NO_TCLTK='$(NO_TCLTK)' install-info: - $(MAKE) -C Documentation install-info + $(MAKE) -C Documentation install-info NO_TCLTK='$(NO_TCLTK)' install-pdf: - $(MAKE) -C Documentation install-pdf + $(MAKE) -C Documentation install-pdf NO_TCLTK='$(NO_TCLTK)' quick-install-doc: - $(MAKE) -C Documentation quick-install + $(MAKE) -C Documentation quick-install NO_TCLTK='$(NO_TCLTK)' quick-install-man: - $(MAKE) -C Documentation quick-install-man + $(MAKE) -C Documentation quick-install-man NO_TCLTK='$(NO_TCLTK)' quick-install-html: - $(MAKE) -C Documentation quick-install-html + $(MAKE) -C Documentation quick-install-html NO_TCLTK='$(NO_TCLTK)' @@ -2875,13 +2875,16 @@ manpages = git-manpages-$(GIT_VERSION) dist-doc: $(RM) -r .doc-tmp-dir mkdir .doc-tmp-dir - $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc + $(MAKE) -C Documentation NO_TCLTK='$(NO_TCLTK)' \ + WEBDOC_DEST=../.doc-tmp-dir install-webdoc cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar . gzip -n -9 -f $(htmldocs).tar : $(RM) -r .doc-tmp-dir mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7 - $(MAKE) -C Documentation DESTDIR=./ \ + $(MAKE) -C Documentation \ + NO_TCLTK='$(NO_TCLTK)' \ + DESTDIR=./ \ man1dir=../.doc-tmp-dir/man1 \ man5dir=../.doc-tmp-dir/man5 \ man7dir=../.doc-tmp-dir/man7 \ @@ -2915,7 +2918,7 @@ clean: profile-clean coverage-clean $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz $(RM) $(htmldocs).tar.gz $(manpages).tar.gz $(RM) contrib/coccinelle/*.cocci.patch* - $(MAKE) -C Documentation/ clean + $(MAKE) -C Documentation/ clean NO_TCLTK='$(NO_TCLTK)' ifndef NO_PERL $(MAKE) -C gitweb clean $(RM) -r perl/build/ @@ -294
Re: [PATCH 1/2] store submodule in common dir
On Wed, Aug 15, 2018 at 1:20 AM Junio C Hamano wrote: > Theoretically we should be able to make modules/kernel%2fv2.[24] > additional "worktree"s of modules/kernel%2fv2.6, but given that > these are all "bare" repositories without an attached working tree, > I am not sure how that would supposed to work. Thinking about > having multiple worktrees on a single bare repository makes me head > spin and ache X-<;-) I could only read the mail subject this morning and thought a bit about it on the train, and came to the same conclusion that "git worktree" is the way to go. The bareness should not affect this at all. If you meant core.bare, it can only affect the main repo. But what I'm thinking is repos with only linked worktrees and no main one. So when you "submodule update" a repo, you "clone -n", then "git worktree add" to put a worktree in place. The repo is strictly speaking not bare, it just does not have a main worktree. The main HEAD should be detached so that it does not block any worktree from checking out branches. If we could get away without the main HEAD, that would be great, but HEAD is part of the repo signature so it has to stay (and we may end up keeping more objects for this HEAD even after every other heads don't need the same objects anymore). This also solves the problem with mupltiple worktrees on a repo with submodules, where we have the same problems (if I add a new worktree of the superproject, where do the new submodules go?). In this case ideally all worktrees should have separate ref namespaces to maintain the "separate repo" view that we currently have, but I guess we can live with sharing refs for a while. And simply sharing $GIT_DIR/modules won't work. For starter, it breaks existing setups. What I've wanted to do is adding a shared "common" directory. Then you could have "common/modules" (among other future common stuff), which is shared across all worktrees, but you don't have to add extra share rules since it's already covered by the "common" rule. -- Duy
Re: [PATCHv3 1/6] Add missing includes and forward declares
On Tue, Aug 14, 2018 at 11:51 PM Elijah Newren wrote: > > [...] > > >> enums are of unknown size, so forward declarations don't work for > > >> them. See bb/pedantic for some examples. > > > > > > structs are also of unknown size; the size is irrelevant when the > > > function signature merely uses a pointer to the struct or enum. The > > > enum forward declaration fixes a compilation bug. > > > > My rationale may miss the point but the standard and some real compilers > > don't like this, unfortunately. > > > > For structs, having an incomplete type is fine, but for enums we need > > the full definition. E.g. C99 sayeth (in section 6.7.2.3 "tags") > > > > A type specifier of the form > > > > enum identifier > > > > without an enumerator list shall only appear after the type it > > specifies is complete. > > What about a type specifier of the form > enum identifier * > ? Can that kind of type specifier appear before the full definition > of the enum? (Or, alternatively, if the standard doesn't say, are > there any compilers that have a problem with that?) > > If so, we can include cache.h instead. We'll probably also have to > fix up packfile.h for the exact same issue (even the same enum name) > if that's the case. Digging a little further this morning, apparently C++ has defined a forward declaration of an enum to either be useless (because it was already defined), require an explicit size specifier, or be a compilation error. That seemed stupid to me, but a little more digging turned up http://c-faq.com/null/machexamp.html , which states that sizeof(char*) != sizeof(int*) on some platforms. That was a big surprise to me. Since an enum could be a char or int (or long or...), knowing the size of the enum thus is important to knowing the size of a pointer to an enum, so we actually do need the full enum definition (or a C++ style explicit size specifier). What a crazy world. So, I'll go with the inclusion of cache.h and also fix up packfile.h the same way. Thanks for pointing this out, Jonathan.
Re: [PATCH 0/9] Add missing includes and forward declares
Elijah Newren writes: > On Tue, Aug 14, 2018 at 10:45 PM Junio C Hamano wrote: >> Elijah Newren writes: >> >> > On Mon, Aug 13, 2018 at 11:24 AM Junio C Hamano wrote: >> >> Jeff King writes: >> > >> >> As things are slowly moving out of the so-far kitchen-sink "cache.h" >> >> into more specific subsystem headers (like object-store.h), we may >> >> actually want to tighten the "header that includes it first" part a >> >> bit in the future, so that 'git grep cache.h' would give us a more >> >> explicit and a better picture of what really depends on knowing what >> >> the lowest level plumbing API are built around. >> >> >> >> > So I think the better test is a two-line .c file with: >> >> > >> >> > #include "git-compat-util.h" >> >> > #include $header_to_check >> >> >> >> But until that tightening happens, I do not actually mind the >> >> two-line .c file started with inclusion of cache.h instead of >> >> git-compat-util.h. That would limit the scope of this series >> >> further. >> > >> > Yes, this removes about 2/3 of patch #1. >> >> Sorry for making a misleading comment. I should have phrased "I >> would not have minded if the series were looser by assuming >> cache.h", implying that "but now the actual patch went extra mile to >> be more complete, what we have is even better ;-)". > > Ah, gotcha. Thanks for the clarification. But please remind me not to merge this round down to 'next', for the "enum" forward decl gotcha.
Re: [PATCH 0/9] Add missing includes and forward declares
On Wed, Aug 15, 2018 at 8:43 AM Junio C Hamano wrote: > Elijah Newren writes: > > > On Tue, Aug 14, 2018 at 10:45 PM Junio C Hamano wrote: > >> Elijah Newren writes: > >> > >> > On Mon, Aug 13, 2018 at 11:24 AM Junio C Hamano > >> > wrote: > >> >> Jeff King writes: > >> > > >> >> As things are slowly moving out of the so-far kitchen-sink "cache.h" > >> >> into more specific subsystem headers (like object-store.h), we may > >> >> actually want to tighten the "header that includes it first" part a > >> >> bit in the future, so that 'git grep cache.h' would give us a more > >> >> explicit and a better picture of what really depends on knowing what > >> >> the lowest level plumbing API are built around. > >> >> > >> >> > So I think the better test is a two-line .c file with: > >> >> > > >> >> > #include "git-compat-util.h" > >> >> > #include $header_to_check > >> >> > >> >> But until that tightening happens, I do not actually mind the > >> >> two-line .c file started with inclusion of cache.h instead of > >> >> git-compat-util.h. That would limit the scope of this series > >> >> further. > >> > > >> > Yes, this removes about 2/3 of patch #1. > >> > >> Sorry for making a misleading comment. I should have phrased "I > >> would not have minded if the series were looser by assuming > >> cache.h", implying that "but now the actual patch went extra mile to > >> be more complete, what we have is even better ;-)". > > > > Ah, gotcha. Thanks for the clarification. > > But please remind me not to merge this round down to 'next', for the > "enum" forward decl gotcha. I'll send out a new round shortly. Would you like me to squash the last patch (the one that had two hunks with minor conflicts with other topics in next and pu) into the first patch, or would you rather I dropped that patch and waited to submit it until later?
Re: [PATCH 0/9] Add missing includes and forward declares
Elijah Newren writes: >> >> But please remind me not to merge this round down to 'next', for the >> "enum" forward decl gotcha. > > I'll send out a new round shortly. Would you like me to squash the > last patch (the one that had two hunks with minor conflicts with other > topics in next and pu) into the first patch, or would you rather I > dropped that patch and waited to submit it until later? Either way is fine, especially if you looked at the intergration result from yesterday and resolution of these conflicts looked reasonable to you.
Re: [PATCH v4 6/6] list-objects-filter: implement filter tree:0
Matthew DeVore writes: > Thank you. I changed it to this: > awk -e "/tree|blob/{print \$1}" objs >trees_and_blobs The "-e" option does not appear in http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html and I think you can safely drop it from your command line. If no -f option is specified, the first operand to awk shall be the text of the awk program. The application shall supply the program operand as a single argument to awk. If the text does not end in a , awk shall interpret the text as if it did.
Re: [PATCH v4 6/6] list-objects-filter: implement filter tree:0
Jeff King writes: > Right, I'd agree they probably want the minimum for that traversal. And > for `rev-list --filter`, that's probably OK. But keep in mind the main > goal for --filter is using it for fetches, and many servers do not > perform the traversal at all. Instead they use reachability bitmaps to > come up with the set of objects to send. The bitmaps have enough > information to say "remove all trees from the set", but not enough to do > any kind of depth-based calculation (not even "is this a root tree"). If the depth-based cutoff turns out to make sense (on which I haven't formed an opinion yet), newer version of pack bitmaps could store that information ;-) How are these "fitler" expressions negotiated between the fetcher and uploader? Does a "fetch-patch" say "am I allowed to ask you to filter with tree:4?" and refrain from using the option when "upload-pack" says "no"?
[PATCH 1/2] branch.c: remove explicit reference to the_repository
Signed-off-by: Nguyễn Thái Ngọc Duy --- branch.c | 22 -- branch.h | 7 +-- builtin/am.c | 2 +- builtin/branch.c | 6 -- builtin/checkout.c | 5 +++-- builtin/reset.c| 2 +- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/branch.c b/branch.c index ecd710d730..0baa1f6877 100644 --- a/branch.c +++ b/branch.c @@ -244,7 +244,8 @@ N_("\n" "will track its remote counterpart, you may want to use\n" "\"git push -u\" to set the upstream config as you push."); -void create_branch(const char *name, const char *start_name, +void create_branch(struct repository *repo, + const char *name, const char *start_name, int force, int clobber_head_ok, int reflog, int quiet, enum branch_track track) { @@ -302,7 +303,8 @@ void create_branch(const char *name, const char *start_name, break; } - if ((commit = lookup_commit_reference(the_repository, &oid)) == NULL) + commit = lookup_commit_reference(repo, &oid); + if (!commit) die(_("Not a valid branch point: '%s'."), start_name); oidcpy(&oid, &commit->object.oid); @@ -338,15 +340,15 @@ void create_branch(const char *name, const char *start_name, free(real_ref); } -void remove_branch_state(void) +void remove_branch_state(struct repository *repo) { - unlink(git_path_cherry_pick_head(the_repository)); - unlink(git_path_revert_head(the_repository)); - unlink(git_path_merge_head(the_repository)); - unlink(git_path_merge_rr(the_repository)); - unlink(git_path_merge_msg(the_repository)); - unlink(git_path_merge_mode(the_repository)); - unlink(git_path_squash_msg(the_repository)); + unlink(git_path_cherry_pick_head(repo)); + unlink(git_path_revert_head(repo)); + unlink(git_path_merge_head(repo)); + unlink(git_path_merge_rr(repo)); + unlink(git_path_merge_msg(repo)); + unlink(git_path_merge_mode(repo)); + unlink(git_path_squash_msg(repo)); } void die_if_checked_out(const char *branch, int ignore_current_worktree) diff --git a/branch.h b/branch.h index 473d0a93e9..14d8282927 100644 --- a/branch.h +++ b/branch.h @@ -3,6 +3,8 @@ /* Functions for acting on the information about branches. */ +struct repository; + /* * Creates a new branch, where: * @@ -24,7 +26,8 @@ * that start_name is a tracking branch for (if any). * */ -void create_branch(const char *name, const char *start_name, +void create_branch(struct repository *repo, + const char *name, const char *start_name, int force, int clobber_head_ok, int reflog, int quiet, enum branch_track track); @@ -47,7 +50,7 @@ extern int validate_new_branchname(const char *name, struct strbuf *ref, int for * Remove information about the state of working on the current * branch. (E.g., MERGE_HEAD) */ -void remove_branch_state(void); +void remove_branch_state(struct repository *); /* * Configure local branch "local" as downstream to branch "remote" diff --git a/builtin/am.c b/builtin/am.c index 2c19e69f58..7abe39939e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2017,7 +2017,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem if (merge_tree(remote_tree)) return -1; - remove_branch_state(); + remove_branch_state(the_repository); return 0; } diff --git a/builtin/branch.c b/builtin/branch.c index 4fc55c3508..e04d528ce1 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -795,7 +795,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix) * create_branch takes care of setting up the tracking * info and making sure new_upstream is correct */ - create_branch(branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); + create_branch(the_repository, branch->name, new_upstream, + 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); } else if (unset_upstream) { struct branch *branch = branch_get(argv[0]); struct strbuf buf = STRBUF_INIT; @@ -831,7 +832,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (track == BRANCH_TRACK_OVERRIDE) die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead.")); - create_branch(argv[0], (argc == 2) ? argv[1] : head, + create_branch(the_repository, + argv[0], (argc == 2) ? argv[1] : head, force, 0, reflog, quiet, track); } else diff --git a/builtin/checkout.c b/builtin/checkout.c index 516136a23a..4756018272 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -653,7 +653,8 @@
[PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
--quit is supposed to be --abort but without restoring HEAD. Leaving CHERRY_PICK_HEAD behind could make other commands mistake that cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to work). Clean it too. For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so we don't need to do anything else. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/revert.c| 9 +++-- t/t3510-cherry-pick-sequence.sh | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index 76f0a35b07..e94a4ead2b 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -7,6 +7,7 @@ #include "rerere.h" #include "dir.h" #include "sequencer.h" +#include "branch.h" /* * This implements the builtins revert and cherry-pick. @@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) opts->gpg_sign = xstrdup_or_null(opts->gpg_sign); opts->strategy = xstrdup_or_null(opts->strategy); - if (cmd == 'q') - return sequencer_remove_state(opts); + if (cmd == 'q') { + int ret = sequencer_remove_state(opts); + if (!ret) + remove_branch_state(the_repository); + return ret; + } if (cmd == 'c') return sequencer_continue(opts); if (cmd == 'a') diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 3505b6aa14..9d121f8ce6 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' ' pristine_detach initial && test_expect_code 1 git cherry-pick base..picked && git cherry-pick --quit && - test_path_is_missing .git/sequencer + test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD ' test_expect_success '--quit keeps HEAD and conflicted index intact' ' -- 2.18.0.1004.g6639190530
Re: Measuring Community Involvement (was Re: Contributor Summit planning)
On Tue, Aug 14, 2018 at 7:43 PM Derrick Stolee wrote: > 2. Number of other commit tag-lines (Reviewed-By, Helped-By, > Reported-By, etc.). > > Using git repo: > > $ git log --since=2018-01-01 junio/next|grep by:|grep -v > Signed-off-by:|sort|uniq -c|sort -nr|head -n 20 > > 66 Reviewed-by: Stefan Beller > 22 Reviewed-by: Jeff King > 19 Reviewed-by: Jonathan Tan > 12 Helped-by: Eric Sunshine > 11 Helped-by: Junio C Hamano >9 Helped-by: Jeff King >8 Reviewed-by: Elijah Newren >7 Reported-by: Ramsay Jones >7 Acked-by: Johannes Schindelin >7 Acked-by: Brandon Williams >6 Reviewed-by: Eric Sunshine >6 Helped-by: Johannes Schindelin >5 Mentored-by: Christian Couder >5 Acked-by: Johannes Schindelin >4 Reviewed-by: Jonathan Nieder >4 Reviewed-by: Johannes Schindelin >4 Helped-by: Stefan Beller >4 Helped-by: René Scharfe >3 Reviewed-by: Martin Ågren >3 Reviewed-by: Lars Schneider > > (There does not appear to be enough density here to make a useful > metric.) If your database keeps mail relationship (e.g. what mail is replied to what according to In-Reply-To header) then look for mail replies to patches. I think we have a rough picture who are active reviewers with that. -- Duy
Re: [PATCH 1/1] chainlint: fix for core.autocrlf=true
"Johannes Schindelin via GitGitGadget" writes: > From: Johannes Schindelin > > The `chainlint` target compares actual output to expected output, where > the actual output is generated from files that are specifically checked > out with LF-only line endings. So the expected output needs to be > checked out with LF-only line endings, too. > > Signed-off-by: Johannes Schindelin > --- > t/.gitattributes | 1 + > 1 file changed, 1 insertion(+) Good spotting. A help like this from those on different platforms than what the original author uses is the ideal model of how we collaborate together. Will queue. > > diff --git a/t/.gitattributes b/t/.gitattributes > index 3bd959ae5..9d09df5a6 100644 > --- a/t/.gitattributes > +++ b/t/.gitattributes > @@ -1,4 +1,5 @@ > t[0-9][0-9][0-9][0-9]/* -whitespace > +/chainlint/*.expect eol=lf > /diff-lib/* eol=lf > /t0110/url-* binary > /t3900/*.txt eol=lf
Re: [PATCH 1/1] chainlint: fix for core.autocrlf=true
On Wed, Aug 15, 2018 at 10:33 AM Johannes Schindelin via GitGitGadget wrote: > The `chainlint` target compares actual output to expected output, where > the actual output is generated from files that are specifically checked > out with LF-only line endings. So the expected output needs to be > checked out with LF-only line endings, too. > > Signed-off-by: Johannes Schindelin > --- > diff --git a/t/.gitattributes b/t/.gitattributes > @@ -1,4 +1,5 @@ > +/chainlint/*.expect eol=lf Make sense. I did touch t/.gitignore for the chainlint series but never thought to examine t/.gitattributes (and wasn't necessarily aware of its existence). Had I looked inside .gitattributes, perhaps I would have intuited the need for this change. Thanks for handling it.
Re: [PATCH v4 2/5] unpack-trees: add performance tracing
On Tue, Aug 14, 2018 at 10:52 PM Junio C Hamano wrote: > > It's not just sampling points. There's things like index id being > > shown in the message for example. I prefer to keep free style format > > to help me read. There's also things like indentation I do here to > > help me read. > > Yup, I do not think that contradicts with the approach to have a > single unified "data collection" API; you should also be able to > specify how that collection of data is to be presented in the trace > messages meant for humans, which would be discarded when emitting > json but would be used when showing human-readble trace, no? Yes. As Peff also pointed out in another mail, as long as this structured logging stuff does not stop me from manual trace messages and don't force more work on me when I add new traces, I don't care if it exists. -- Duy
Re: [PATCH v4 6/6] list-objects-filter: implement filter tree:0
On Wed, Aug 15, 2018 at 9:14 AM Junio C Hamano wrote: > > Matthew DeVore writes: > > > Thank you. I changed it to this: > > awk -e "/tree|blob/{print \$1}" objs >trees_and_blobs > > The "-e" option does not appear in > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html > > and I think you can safely drop it from your command line. Fixed it, thank you. It will be in the next patchset version. > > If no -f option is specified, the first operand to awk shall be the > text of the awk program. The application shall supply the program > operand as a single argument to awk. If the text does not end in a > , awk shall interpret the text as if it did. >
Re: [PATCH v4 3/5] unpack-trees: optimize walking same trees with cache-tree
On Mon, Aug 13, 2018 at 8:58 PM Ben Peart wrote: > > + * > > + * D/F conflicts and higher stage entries are not a concern > > + * because cache-tree would be invalidated and we would never > > + * get here in the first place. > > + */ > > + for (i = 0; i < nr_entries; i++) { > > + struct cache_entry *tree_ce; > > + int len, rc; > > + > > + src[0] = o->src_index->cache[pos + i]; > > + > > + len = ce_namelen(src[0]); > > + tree_ce = xcalloc(1, cache_entry_size(len)); > > + > > + tree_ce->ce_mode = src[0]->ce_mode; > > + tree_ce->ce_flags = create_ce_flags(0); > > + tree_ce->ce_namelen = len; > > + oidcpy(&tree_ce->oid, &src[0]->oid); > > + memcpy(tree_ce->name, src[0]->name, len + 1); > > + > > + for (d = 1; d <= nr_names; d++) > > + src[d] = tree_ce; > > + > > + rc = call_unpack_fn((const struct cache_entry * const *)src, > > o); > > I don't fully understand why this is still necessary since "we detect > that all trees are the same as cache-tree at this path." I do know > (because I tried it :)) that if we don't actually call the unpack > function the patch fails a bunch of tests so clearly something important > is being missed. Yeah because removing this line assumes n-way logic, which most likely means "use the index version if all trees are the same as the index" but it's not necessarily true. There could be flags that make n-way behave differently. And even if we make that assumption, we need to copy src[0] to o->result (heh I tried that "skip call_unpack_fn" thing too when I thought this would be the same as the diff-index --cached optimization path, and only realized copying to o->result was needed afterwards). -- Duy
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 9:24 AM Nguyễn Thái Ngọc Duy wrote: The patch looks good, but since this touches multiple .c files, I think I'd s/branch.c/branch/ in the subject line. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > branch.c | 22 -- > branch.h | 7 +-- > builtin/am.c | 2 +- > builtin/branch.c | 6 -- > builtin/checkout.c | 5 +++-- > builtin/reset.c| 2 +- > 6 files changed, 26 insertions(+), 18 deletions(-) > > diff --git a/branch.c b/branch.c > index ecd710d730..0baa1f6877 100644 > --- a/branch.c > +++ b/branch.c > @@ -244,7 +244,8 @@ N_("\n" > "will track its remote counterpart, you may want to use\n" > "\"git push -u\" to set the upstream config as you push."); > > -void create_branch(const char *name, const char *start_name, > +void create_branch(struct repository *repo, > + const char *name, const char *start_name, >int force, int clobber_head_ok, int reflog, >int quiet, enum branch_track track) > { > @@ -302,7 +303,8 @@ void create_branch(const char *name, const char > *start_name, > break; > } > > - if ((commit = lookup_commit_reference(the_repository, &oid)) == NULL) > + commit = lookup_commit_reference(repo, &oid); > + if (!commit) > die(_("Not a valid branch point: '%s'."), start_name); > oidcpy(&oid, &commit->object.oid); > > @@ -338,15 +340,15 @@ void create_branch(const char *name, const char > *start_name, > free(real_ref); > } > > -void remove_branch_state(void) > +void remove_branch_state(struct repository *repo) > { > - unlink(git_path_cherry_pick_head(the_repository)); > - unlink(git_path_revert_head(the_repository)); > - unlink(git_path_merge_head(the_repository)); > - unlink(git_path_merge_rr(the_repository)); > - unlink(git_path_merge_msg(the_repository)); > - unlink(git_path_merge_mode(the_repository)); > - unlink(git_path_squash_msg(the_repository)); > + unlink(git_path_cherry_pick_head(repo)); > + unlink(git_path_revert_head(repo)); > + unlink(git_path_merge_head(repo)); > + unlink(git_path_merge_rr(repo)); > + unlink(git_path_merge_msg(repo)); > + unlink(git_path_merge_mode(repo)); > + unlink(git_path_squash_msg(repo)); > } > > void die_if_checked_out(const char *branch, int ignore_current_worktree) > diff --git a/branch.h b/branch.h > index 473d0a93e9..14d8282927 100644 > --- a/branch.h > +++ b/branch.h > @@ -3,6 +3,8 @@ > > /* Functions for acting on the information about branches. */ > > +struct repository; > + > /* > * Creates a new branch, where: > * > @@ -24,7 +26,8 @@ > * that start_name is a tracking branch for (if any). > * > */ > -void create_branch(const char *name, const char *start_name, > +void create_branch(struct repository *repo, > + const char *name, const char *start_name, >int force, int clobber_head_ok, >int reflog, int quiet, enum branch_track track); > > @@ -47,7 +50,7 @@ extern int validate_new_branchname(const char *name, struct > strbuf *ref, int for > * Remove information about the state of working on the current > * branch. (E.g., MERGE_HEAD) > */ > -void remove_branch_state(void); > +void remove_branch_state(struct repository *); > > /* > * Configure local branch "local" as downstream to branch "remote" > diff --git a/builtin/am.c b/builtin/am.c > index 2c19e69f58..7abe39939e 100644 > --- a/builtin/am.c > +++ b/builtin/am.c > @@ -2017,7 +2017,7 @@ static int clean_index(const struct object_id *head, > const struct object_id *rem > if (merge_tree(remote_tree)) > return -1; > > - remove_branch_state(); > + remove_branch_state(the_repository); > > return 0; > } > diff --git a/builtin/branch.c b/builtin/branch.c > index 4fc55c3508..e04d528ce1 100644 > --- a/builtin/branch.c > +++ b/builtin/branch.c > @@ -795,7 +795,8 @@ int cmd_branch(int argc, const char **argv, const char > *prefix) > * create_branch takes care of setting up the tracking > * info and making sure new_upstream is correct > */ > - create_branch(branch->name, new_upstream, 0, 0, 0, quiet, > BRANCH_TRACK_OVERRIDE); > + create_branch(the_repository, branch->name, new_upstream, > + 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); > } else if (unset_upstream) { > struct branch *branch = branch_get(argv[0]); > struct strbuf buf = STRBUF_INIT; > @@ -831,7 +832,8 @@ int cmd_branch(int argc, const char **argv, const char > *prefix) > if (track == BRANCH_TRACK_OVERRIDE) > die(_("the '--set-upstream' option is no longer > supported. Please use '--track' or '--set-upstream-to' instead.")); > > -
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 6:48 PM Elijah Newren wrote: > > On Wed, Aug 15, 2018 at 9:24 AM Nguyễn Thái Ngọc Duy > wrote: > > The patch looks good, but since this touches multiple .c files, I > think I'd s/branch.c/branch/ in the subject line. It is about removing the_repository from branch.c though. As much as I want to completely erase the_repository, that would take a lot more work. -- Duy
Re: [PATCH] Makefile: extend NO_TCLTK=NoThanks to cover docs
Ævar Arnfjörð Bjarmason writes: > Extend the NO_TCLTK=NoThanks flag to be understood by the > Documentation Makefile. > > Before this change compiling and installing with NO_TCLTK would result > in no git-gui, gitk or git-citool being installed, but their > respective manual pages would still be installed. Thanks, but I personally do not perceive it to be a problem. It is perfectly OK to install programs without installing docs, and also it is OK to install docs without programs. I do not see why gitk.html and the reference to it from the main ToC in git.html must be removed when you are not installing gitk. Lack of an option to skip them from the documentation is something we might want to improve, but you should be able to install the docs for programs you do not happen to have, and I think it should be the default. By the way, to be more explicit than merely to hint, I think this patch needs to also update Documentation/cmd-list.perl so that under NO_TCLTK, the entry for gitk is omitted from cmds-mainporcelain.txt, etc. to be a complete solution to your original problem. > Signed-off-by: Ævar Arnfjörð Bjarmason > --- > Documentation/Makefile | 23 ++- > Makefile | 39 +-- > 2 files changed, 39 insertions(+), 23 deletions(-) > > diff --git a/Documentation/Makefile b/Documentation/Makefile > index d079d7c73a..d53979939e 100644 > --- a/Documentation/Makefile > +++ b/Documentation/Makefile > @@ -1,5 +1,7 @@ > # Guard against environment variables > MAN1_TXT = > +MAN1_TXT_WIP = > +TCLTK_FILES = The latter name loses the fact that it is to hold candidates to be on MAN1_TXT that happen to be conditionally included; calling it MAN1_TXT_TCLTK or something, perhaps, may be an improvement. The former name makes it look it is work-in-progress, but in fact they are definite and unconditional part of MAN1_TXT. Perhaps MAN1_TXT_CORE or something? > ... > +MAN1_TXT_WIP += git.txt > +MAN1_TXT_WIP += gitremote-helpers.txt > +MAN1_TXT_WIP += gitweb.txt > + > +ifndef NO_TCLTK > +MAN1_TXT_WIP += gitk.txt > +MAN1_TXT = $(MAN1_TXT_WIP) > +else > +TCLTK_FILES += git-gui.txt > +TCLTK_FILES += gitk.txt > +TCLTK_FILES += git-citool.txt > +MAN1_TXT = $(filter-out \ > + $(TCLTK_FILES), \ > + $(MAN1_TXT_WIP)) > +endif > > MAN5_TXT += gitattributes.txt > MAN5_TXT += githooks.txt > diff --git a/Makefile b/Makefile > index bc4fc8eeab..8abb23f6ce 100644 > --- a/Makefile > +++ b/Makefile > @@ -2372,21 +2372,21 @@ export DEFAULT_EDITOR DEFAULT_PAGER > > .PHONY: doc man man-perl html info pdf > doc: man-perl > - $(MAKE) -C Documentation all > + $(MAKE) -C Documentation all NO_TCLTK='$(NO_TCLTK)' > ... > pdf: > - $(MAKE) -C Documentation pdf > + $(MAKE) -C Documentation pdf NO_TCLTK='$(NO_TCLTK)' Since we are assuming GNU make anyway, can we just say "export NO_TCLTK" just once, or would it be too magical and create maintenance burden?
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 9:53 AM Duy Nguyen wrote: > > On Wed, Aug 15, 2018 at 6:48 PM Elijah Newren wrote: > > > > On Wed, Aug 15, 2018 at 9:24 AM Nguyễn Thái Ngọc Duy > > wrote: > > > > The patch looks good, but since this touches multiple .c files, I > > think I'd s/branch.c/branch/ in the subject line. > > It is about removing the_repository from branch.c though. As much as I > want to completely erase the_repository, that would take a lot more > work. What is your envisioned end state? 1) IMHO we'd first want to put the_repository in place where needed, 2) then start replacing s/the_repository/a repository/ in / 3) builtin/ is not critical, but we'd want to do that later 4) eventually (in the very long run), we'd change the signature of all commands from cmd_foo(int argc, char argv, char *prefix) to cmd_foo(int argc, char argv, struct repository *repo) you seem to be interested in removing the_repository from branch.c, but not as much from bultin/ for now, which is roughly step 2 in that plan?
Re: [PATCH] branch: support configuring --sort via .gitconfig
On Wed, Aug 15, 2018 at 7:16 AM wrote: > Add support for configuring default sort ordering for git branches. Command > line option will override this configured value, using the exact same > syntax. Your Signed-off-by: is missing. See Documentation/SubmittingPatches. > diff --git a/Documentation/config.txt b/Documentation/config.txt > @@ -1034,6 +1034,11 @@ branch.autoSetupRebase:: > +branch.sort:: > + This variable controls the sort ordering of branches when displayed by > + linkgit:git-branch[1]. Without the "--sort=" option provided, > the > + value of this variable will be used as the default. I realize that you copied this description from 'tag.sort', thus inherited its existing weakness, but as a reader of this, the first question which popped into my head was "what are the possible s? This description gives no clues and leaves the reader hanging. Better would be either to list the values or point the reader (possibly with a linkgit:) at documentation which does list them. > diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt > @@ -272,6 +272,10 @@ start-point is either a local or remote-tracking branch. > full refname (including `refs/...` prefix). This lists > detached HEAD (if present) first, then local branches and > finally remote-tracking branches. > + The keys supported are the same as those in `git for-each-ref`. > + Sort order defaults to the value configured for the `tag.sort` Did you mean s/tag/branch/? > + variable if it exists, or lexicographic order otherwise. See > + linkgit:git-config[1]. Except for the "See linkgit:git-config[1]", isn't this new text mostly duplicating what this item already says? When I look at Documentation/git-branch.txt, I see: Sort based on the key given. Prefix `-` to sort in descending order of the value. You may use the --sort= option multiple times, in which case the last key becomes the primary key. **The keys supported are the same as those in `git for-each-ref`. Sort order defaults to** sorting based on the full refname (including `refs/...` prefix). This lists detached HEAD (if present) first, then local branches and finally remote-tracking branches. I added ** to highlight the existing text which this duplicates. > diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh > @@ -1305,4 +1305,50 @@ test_expect_success 'tracking with unexpected .fetch > refspec' ' > +test_expect_success 'configured committerdate sort' ' > + git init sort && > + ( > + cd sort && > + git config branch.sort committerdate && > + [...] > + ) > +' > + > +test_expect_success 'option override configured sort' ' > + ( > + cd sort && > + git branch --sort=refname >actual && I would trust this test more if it explicitly configured "branch.sort" rather than inheriting the value from test(s) above it. That way you wouldn't have to worry about someone later inserting a test above this one which changes or removes the value. > + cat >expect <<-\EOF && > + a > + * b > + c > + master > + EOF > + test_cmp expect actual > + ) > +' > + > +test_expect_success 'invalid sort parameter in configuration' ' > + ( > + cd sort && > + git config branch.sort "v:notvalid" && > + test_must_fail git branch > + > + ) > +' Style: Lose the unnecessary blank line. Thanks.
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
On Wed, Aug 15, 2018 at 9:23 AM Nguyễn Thái Ngọc Duy wrote: > > --quit is supposed to be --abort but without restoring HEAD. Leaving > CHERRY_PICK_HEAD behind could make other commands mistake that > cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to > work). Clean it too. > > For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so > we don't need to do anything else. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > builtin/revert.c| 9 +++-- > t/t3510-cherry-pick-sequence.sh | 3 ++- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/builtin/revert.c b/builtin/revert.c > index 76f0a35b07..e94a4ead2b 100644 > --- a/builtin/revert.c > +++ b/builtin/revert.c > @@ -7,6 +7,7 @@ > #include "rerere.h" > #include "dir.h" > #include "sequencer.h" > +#include "branch.h" > > /* > * This implements the builtins revert and cherry-pick. > @@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, > struct replay_opts *opts) > opts->gpg_sign = xstrdup_or_null(opts->gpg_sign); > opts->strategy = xstrdup_or_null(opts->strategy); > > - if (cmd == 'q') > - return sequencer_remove_state(opts); > + if (cmd == 'q') { > + int ret = sequencer_remove_state(opts); > + if (!ret) > + remove_branch_state(the_repository); Technically you would not need patch 1 in this series, as you could call remove_branch_state(void) as before that patch to do the same thing here. I guess that patch 1 is more of a drive by cleanup, then? It looks a bit interesting as sequencer_remove_state actually takes no arguments and assumes the_repository, but I guess that is fine. I wondered if we need to have this patch for 'a' as well, and it looks like which does a sequencer_rollback, which is just some logic before attempting sequencer_remove_state. So I'd think remove_branch_state could be done in sequencer_remove_state as well? Or are there functions that would definitely not want sequencer_remove_state after sequencer_remove_state? Going down on that I just realize sequencer_remove_state could also be returning void, as of now it always returns 0, so the condition here with !ret is just confusing the reader? Thanks, Stefan
Re: [PATCH] Makefile: extend NO_TCLTK=NoThanks to cover docs
Junio C Hamano writes: >> # Guard against environment variables >> MAN1_TXT = >> +MAN1_TXT_WIP = >> +TCLTK_FILES = > > The latter name loses the fact that it is to hold candidates to be > on MAN1_TXT that happen to be conditionally included; calling it > MAN1_TXT_TCLTK or something, perhaps, may be an improvement. > > The former name makes it look it is work-in-progress, but in fact > they are definite and unconditional part of MAN1_TXT. Perhaps > MAN1_TXT_CORE or something? Sorry, I misread the patch. You collect all possible MAN1_TXT candidates on _WIP, so "this is unconditional core part" is wrong. Work-in-progress still sounds a bit funny, but now I know what is going on a bit better, it has become at last understandable ;-) >> +ifndef NO_TCLTK >> +MAN1_TXT_WIP += gitk.txt >> +MAN1_TXT = $(MAN1_TXT_WIP) >> +else >> +TCLTK_FILES += git-gui.txt >> +TCLTK_FILES += gitk.txt >> +TCLTK_FILES += git-citool.txt >> +MAN1_TXT = $(filter-out \ >> +$(TCLTK_FILES), \ >> +$(MAN1_TXT_WIP)) >> +endif I didn't notice it when I read it for the first time, but asymmetry between these two looks somewhat strange. If we are adding gitk.txt when we are not declining TCLTK based programs, why can we do without adding git-gui and git-citool at the same time? If we know we must add gitk.txt when we are not declining TCLTK based programs to MAN1_TXT_WIP in this section, it must mean that when we do not want TCLTK based programs, MAN1_TXT_WIP would not have gitk.txt on it, so why do we even need it on TCLTK_FILES list to filter it out?
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 6:58 PM Stefan Beller wrote: > > On Wed, Aug 15, 2018 at 9:53 AM Duy Nguyen wrote: > > > > On Wed, Aug 15, 2018 at 6:48 PM Elijah Newren wrote: > > > > > > On Wed, Aug 15, 2018 at 9:24 AM Nguyễn Thái Ngọc Duy > > > wrote: > > > > > > The patch looks good, but since this touches multiple .c files, I > > > think I'd s/branch.c/branch/ in the subject line. > > > > It is about removing the_repository from branch.c though. As much as I > > want to completely erase the_repository, that would take a lot more > > work. > > What is your envisioned end state? > > 1) IMHO we'd first want to put the_repository in place where needed, > 2) then start replacing s/the_repository/a repository/ in / > 3) builtin/ is not critical, but we'd want to do that later > 4) eventually (in the very long run), we'd change the signature of > all commands from cmd_foo(int argc, char argv, char *prefix) > to cmd_foo(int argc, char argv, struct repository *repo) > > you seem to be interested in removing the_repository from branch.c, > but not as much from bultin/ for now, which is roughly step 2 in that plan? Yes. Though I think step 4 is to make setup_git_directory() and enter_repo() return a 'struct repository *'. This means if you have not called either function and not take the repo as an argument, you do not have access to any repository. I've been trying to make setup_git_directory() not touch any global variables, which would be the first step towards that. Unfortunately I'm currently stopped at the one exception called "git init". -- Duy
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
On Wed, Aug 15, 2018 at 7:09 PM Stefan Beller wrote: > Technically you would not need patch 1 in this series, as you could call > remove_branch_state(void) as before that patch to do the same thing here. > I guess that patch 1 is more of a drive by cleanup, then? Yes. > It looks a bit interesting as sequencer_remove_state actually > takes no arguments and assumes the_repository, but I guess that is fine. Don't worry. My effort to kill the_index will make sequencer.c take 'struct repository *' (its operations are so wide that passing just struct index_state * does not make sense). > I wondered if we need to have this patch for 'a' as well, and it looks like > which does a sequencer_rollback, which is just some logic before > attempting sequencer_remove_state. So I'd think remove_branch_state > could be done in sequencer_remove_state as well? sequencer_rollback does not need this remove_branch_state() line because it calls reset_for_rollback() which does this deletion. Patch 1/1 kinda hints at that because it touches all remove_branch_state() ;-) Another part of the reason I did not put remove_branch_state() in sequencer_remove_state() is I was not sure if it could be used in a different way (I did not study all of its call sites and am not very familiar with sequencer code). > Or are there functions that would definitely not want sequencer_remove_state > after sequencer_remove_state? > > Going down on that I just realize sequencer_remove_state could also > be returning void, as of now it always returns 0, so the condition here > with !ret is just confusing the reader? -- Duy
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
Duy Nguyen writes: > On Wed, Aug 15, 2018 at 6:48 PM Elijah Newren wrote: >> >> On Wed, Aug 15, 2018 at 9:24 AM Nguyễn Thái Ngọc Duy >> wrote: >> >> The patch looks good, but since this touches multiple .c files, I >> think I'd s/branch.c/branch/ in the subject line. > > It is about removing the_repository from branch.c though. As much as I > want to completely erase the_repository, that would take a lot more > work. I do not think this is about removing the_repository from branch.c; it is primarily about allowing create_branch() to work on an arbitrary repository instance. I also do not think remove_branch_state() function belongs to branch.c in the first place. The state it is clearing is not even about a "branch". It is state left by the last command that stopped in the middle; its only callers are "reset", "am --abort/--skip" and "checkout ".
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
On Wed, Aug 15, 2018 at 10:18 AM Duy Nguyen wrote: > > On Wed, Aug 15, 2018 at 7:09 PM Stefan Beller wrote: > > Technically you would not need patch 1 in this series, as you could call > > remove_branch_state(void) as before that patch to do the same thing here. > > I guess that patch 1 is more of a drive by cleanup, then? > > Yes. > > > It looks a bit interesting as sequencer_remove_state actually > > takes no arguments and assumes the_repository, but I guess that is fine. > > Don't worry. My effort to kill the_index will make sequencer.c take > 'struct repository *' (its operations are so wide that passing just > struct index_state * does not make sense). Cool! I'll give that series a read, then! Thanks for killing the_index! > > I wondered if we need to have this patch for 'a' as well, and it looks like > > which does a sequencer_rollback, which is just some logic before > > attempting sequencer_remove_state. So I'd think remove_branch_state > > could be done in sequencer_remove_state as well? > > sequencer_rollback does not need this remove_branch_state() line > because it calls reset_for_rollback() which does this deletion. Patch > 1/1 kinda hints at that because it touches all remove_branch_state() > ;-) Gah! I am being slow.
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 7:20 PM Junio C Hamano wrote: > I also do not think remove_branch_state() function belongs to > branch.c in the first place. The state it is clearing is not even > about a "branch". It is state left by the last command that stopped > in the middle; its only callers are "reset", "am --abort/--skip" and > "checkout ". sequencer.c as its new home then? -- Duy
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
Nguyễn Thái Ngọc Duy writes: > --quit is supposed to be --abort but without restoring HEAD. Leaving > CHERRY_PICK_HEAD behind could make other commands mistake that > cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to > work). Clean it too. > > For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so > we don't need to do anything else. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- Please do not hide this bugfix behind 1/2 that is likely to require longer to cook than the fix itself. And more importantly, it makes it impossible to merge down the fix to the maintenance track, as I do not think we'd want to merge 1/2 there. Thanks. > builtin/revert.c| 9 +++-- > t/t3510-cherry-pick-sequence.sh | 3 ++- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/builtin/revert.c b/builtin/revert.c > index 76f0a35b07..e94a4ead2b 100644 > --- a/builtin/revert.c > +++ b/builtin/revert.c > @@ -7,6 +7,7 @@ > #include "rerere.h" > #include "dir.h" > #include "sequencer.h" > +#include "branch.h" > > /* > * This implements the builtins revert and cherry-pick. > @@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, > struct replay_opts *opts) > opts->gpg_sign = xstrdup_or_null(opts->gpg_sign); > opts->strategy = xstrdup_or_null(opts->strategy); > > - if (cmd == 'q') > - return sequencer_remove_state(opts); > + if (cmd == 'q') { > + int ret = sequencer_remove_state(opts); > + if (!ret) > + remove_branch_state(the_repository); > + return ret; > + } > if (cmd == 'c') > return sequencer_continue(opts); > if (cmd == 'a') > diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh > index 3505b6aa14..9d121f8ce6 100755 > --- a/t/t3510-cherry-pick-sequence.sh > +++ b/t/t3510-cherry-pick-sequence.sh > @@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' ' > pristine_detach initial && > test_expect_code 1 git cherry-pick base..picked && > git cherry-pick --quit && > - test_path_is_missing .git/sequencer > + test_path_is_missing .git/sequencer && > + test_path_is_missing .git/CHERRY_PICK_HEAD > ' > > test_expect_success '--quit keeps HEAD and conflicted index intact' '
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
On Wed, Aug 15, 2018 at 7:26 PM Junio C Hamano wrote: > > Nguyễn Thái Ngọc Duy writes: > > > --quit is supposed to be --abort but without restoring HEAD. Leaving > > CHERRY_PICK_HEAD behind could make other commands mistake that > > cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to > > work). Clean it too. > > > > For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so > > we don't need to do anything else. > > > > Signed-off-by: Nguyễn Thái Ngọc Duy > > --- > > Please do not hide this bugfix behind 1/2 that is likely to require > longer to cook than the fix itself. And more importantly, it makes > it impossible to merge down the fix to the maintenance track, as I > do not think we'd want to merge 1/2 there. Oh sorry I did not think about that. Will drop 1/2 and send 2/2 as standalone. But for the record, I think this has been a bug since the introduction of --quit in this command (back when it was still called --reset). -- Duy
Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
Duy Nguyen writes: > On Wed, Aug 15, 2018 at 7:26 PM Junio C Hamano wrote: >> >> Please do not hide this bugfix behind 1/2 that is likely to require >> longer to cook than the fix itself. And more importantly, it makes >> it impossible to merge down the fix to the maintenance track, as I >> do not think we'd want to merge 1/2 there. > > Oh sorry I did not think about that. Will drop 1/2 and send 2/2 as > standalone. But for the record, I think this has been a bug since the > introduction of --quit in this command (back when it was still called > --reset). If this bug has been there longer, it is a reason why we may want to ensure that the fix applies to even older maintenance tracks. Thanks.
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
Duy Nguyen writes: >> 4) eventually (in the very long run), we'd change the signature of >> all commands from cmd_foo(int argc, char argv, char *prefix) >> to cmd_foo(int argc, char argv, struct repository *repo) >> >> you seem to be interested in removing the_repository from branch.c, >> but not as much from bultin/ for now, which is roughly step 2 in that plan? > > Yes. Though I think step 4 is to make setup_git_directory() and > enter_repo() return a 'struct repository *'. This means if you have > not called either function and not take the repo as an argument, you > do not have access to any repository. That part is understandable if somewhat hand-wavy, but it is not clear how you can lose the prefix and still keep things like OPT_FILENAME() working correctly.
Re: [PATCH 1/2] branch.c: remove explicit reference to the_repository
On Wed, Aug 15, 2018 at 7:38 PM Junio C Hamano wrote: > > Duy Nguyen writes: > > >> 4) eventually (in the very long run), we'd change the signature of > >> all commands from cmd_foo(int argc, char argv, char *prefix) > >> to cmd_foo(int argc, char argv, struct repository *repo) > >> > >> you seem to be interested in removing the_repository from branch.c, > >> but not as much from bultin/ for now, which is roughly step 2 in that plan? > > > > Yes. Though I think step 4 is to make setup_git_directory() and > > enter_repo() return a 'struct repository *'. This means if you have > > not called either function and not take the repo as an argument, you > > do not have access to any repository. > > That part is understandable if somewhat hand-wavy, but it is not > clear how you can lose the prefix and still keep things like > OPT_FILENAME() working correctly. I haven't worked it all out yet, but I think setup_git_directory() could still return it either as a separate argument or inside 'struct repository'. Then parse_options() still takes the prefix like now, or take the struct repository (the latter may be better because there's also other option callbacks that need struct repo). -- Duy
[PATCHv4 4/6] urlmatch.h: fix include guard
Reviewed-by: Jonathan Nieder Signed-off-by: Elijah Newren --- urlmatch.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/urlmatch.h b/urlmatch.h index 37ee5da85e..e482148248 100644 --- a/urlmatch.h +++ b/urlmatch.h @@ -1,4 +1,6 @@ #ifndef URL_MATCH_H +#define URL_MATCH_H + #include "string-list.h" struct url_info { -- 2.18.0.553.g74975b7909
[PATCHv4 6/6] Remove forward declaration of an enum
According to http://c-faq.com/null/machexamp.html, sizeof(char*) != sizeof(int*) on some platforms. Since an enum could be a char or int (or long or...), knowing the size of the enum thus is important to knowing the size of a pointer to an enum, so we cannot just forward declare an enum the way we can a struct. (Also, modern C++ compilers apparently define forward declarations of an enum to either be useless because the enum was defined, or require an explicit size specifier, or be a compilation error.) Helped-by: Jonathan Nieder Signed-off-by: Elijah Newren --- packfile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packfile.h b/packfile.h index cc7eaffe1b..fa36c473ad 100644 --- a/packfile.h +++ b/packfile.h @@ -1,12 +1,12 @@ #ifndef PACKFILE_H #define PACKFILE_H +#include "cache.h" #include "oidset.h" /* in object-store.h */ struct packed_git; struct object_info; -enum object_type; /* * Generate the filename to be used for a pack file with checksum "sha1" and -- 2.18.0.553.g74975b7909
Re: [PATCH v4 6/6] list-objects-filter: implement filter tree:0
On Wed, Aug 15, 2018 at 9:17 AM Junio C Hamano wrote: > > Jeff King writes: > > > Right, I'd agree they probably want the minimum for that traversal. And > > for `rev-list --filter`, that's probably OK. But keep in mind the main > > goal for --filter is using it for fetches, and many servers do not > > perform the traversal at all. Instead they use reachability bitmaps to > > come up with the set of objects to send. The bitmaps have enough > > information to say "remove all trees from the set", but not enough to do > > any kind of depth-based calculation (not even "is this a root tree"). > > If the depth-based cutoff turns out to make sense (on which I > haven't formed an opinion yet), newer version of pack bitmaps could > store that information ;-) > > How are these "fitler" expressions negotiated between the fetcher > and uploader? Does a "fetch-patch" say "am I allowed to ask you to > filter with tree:4?" and refrain from using the option when > "upload-pack" says "no"? I couldn't find a feature like that for the existing features, but adding such a think seems reasonable to me. (thinking in terms of protocol v2,) There could be a filter-check command which takes a single argument: the filter string (like "tree:4"), and responds with a single line: either "ok" or "unsupported".
[PATCHv4 5/6] compat/precompose_utf8.h: use more common include guard style
Reviewed-by: Jonathan Nieder Signed-off-by: Elijah Newren --- compat/precompose_utf8.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/precompose_utf8.h b/compat/precompose_utf8.h index a94e7c4342..6f843d3e1a 100644 --- a/compat/precompose_utf8.h +++ b/compat/precompose_utf8.h @@ -1,4 +1,6 @@ #ifndef PRECOMPOSE_UNICODE_H +#define PRECOMPOSE_UNICODE_H + #include #include #include @@ -41,5 +43,4 @@ int precompose_utf8_closedir(PREC_DIR *dirp); #define DIR PREC_DIR #endif /* PRECOMPOSE_UNICODE_C */ -#define PRECOMPOSE_UNICODE_H #endif /* PRECOMPOSE_UNICODE_H */ -- 2.18.0.553.g74975b7909
[PATCHv4 1/6] Add missing includes and forward declarations
I looped over the toplevel header files, creating a temporary two-line C program for each consisting of #include "git-compat-util.h" #include $HEADER This patch is the result of manually fixing errors in compiling those tiny programs. Signed-off-by: Elijah Newren --- alloc.h | 2 ++ apply.h | 3 +++ archive.h | 1 + attr.h| 1 + bisect.h | 2 ++ branch.h | 2 ++ bulk-checkin.h| 2 ++ column.h | 1 + commit-graph.h| 1 + config.h | 5 + connected.h | 1 + convert.h | 2 ++ csum-file.h | 2 ++ diffcore.h| 4 dir-iterator.h| 2 ++ fsck.h| 1 + fsmonitor.h | 3 +++ gpg-interface.h | 2 ++ khash.h | 3 +++ list-objects-filter.h | 4 list-objects.h| 4 ll-merge.h| 2 ++ mailinfo.h| 2 ++ mailmap.h | 2 ++ merge-recursive.h | 4 +++- notes-merge.h | 4 notes-utils.h | 3 +++ notes.h | 3 +++ object-store.h| 1 + object.h | 2 ++ oidmap.h | 1 + pack-bitmap.h | 3 +++ pack-objects.h| 1 + patch-ids.h | 6 ++ path.h| 1 + pathspec.h| 2 ++ pretty.h | 4 reachable.h | 2 ++ reflog-walk.h | 1 + refs.h| 2 ++ remote.h | 1 + repository.h | 2 ++ resolve-undo.h| 2 ++ revision.h| 1 + send-pack.h | 4 sequencer.h | 5 + shortlog.h| 2 ++ submodule.h | 10 -- tempfile.h| 1 + trailer.h | 2 ++ tree-walk.h | 2 ++ unpack-trees.h| 5 - url.h | 2 ++ utf8.h| 2 ++ worktree.h| 1 + 55 files changed, 132 insertions(+), 4 deletions(-) diff --git a/alloc.h b/alloc.h index 3e4e828db4..7a41bb9eb3 100644 --- a/alloc.h +++ b/alloc.h @@ -1,9 +1,11 @@ #ifndef ALLOC_H #define ALLOC_H +struct alloc_state; struct tree; struct commit; struct tag; +struct repository; void *alloc_blob_node(struct repository *r); void *alloc_tree_node(struct repository *r); diff --git a/apply.h b/apply.h index b80d8ba736..0b70e1f3f5 100644 --- a/apply.h +++ b/apply.h @@ -1,6 +1,9 @@ #ifndef APPLY_H #define APPLY_H +#include "lockfile.h" +#include "string-list.h" + enum apply_ws_error_action { nowarn_ws_error, warn_on_ws_error, diff --git a/archive.h b/archive.h index 1f9954f7cd..7aba133635 100644 --- a/archive.h +++ b/archive.h @@ -1,6 +1,7 @@ #ifndef ARCHIVE_H #define ARCHIVE_H +#include "cache.h" #include "pathspec.h" struct archiver_args { diff --git a/attr.h b/attr.h index 442d464db6..3185538bda 100644 --- a/attr.h +++ b/attr.h @@ -7,6 +7,7 @@ struct git_attr; /* opaque structures used internally for attribute collection */ struct all_attrs_item; struct attr_stack; +struct index_state; /* * Given a string, return the gitattribute object that diff --git a/bisect.h b/bisect.h index a5d9248a47..34df209351 100644 --- a/bisect.h +++ b/bisect.h @@ -1,6 +1,8 @@ #ifndef BISECT_H #define BISECT_H +struct commit_list; + /* * Find bisection. If something is found, `reaches` will be the number of * commits that the best commit reaches. `all` will be the count of diff --git a/branch.h b/branch.h index 473d0a93e9..7d9b330eba 100644 --- a/branch.h +++ b/branch.h @@ -1,6 +1,8 @@ #ifndef BRANCH_H #define BRANCH_H +struct strbuf; + /* Functions for acting on the information about branches. */ /* diff --git a/bulk-checkin.h b/bulk-checkin.h index a85527318b..f438f93811 100644 --- a/bulk-checkin.h +++ b/bulk-checkin.h @@ -4,6 +4,8 @@ #ifndef BULK_CHECKIN_H #define BULK_CHECKIN_H +#include "cache.h" + extern int index_bulk_checkin(struct object_id *oid, int fd, size_t size, enum object_type type, const char *path, unsigned flags); diff --git a/column.h b/column.h index 0a61917fa7..2567a5cf4d 100644 --- a/column.h +++ b/column.h @@ -36,6 +36,7 @@ static inline int column_active(unsigned int colopts) return (colopts & COL_ENABLE_MASK) == COL_ENABLED; } +struct string_list; extern void print_columns(const struct string_list *list, unsigned int colopts, const struct column_options *opts); diff --git a/commit-graph.h b/commit-graph.h index 76e098934a..eea62f8c0e 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -4,6 +4,7 @@ #include "git-compat-util.h" #include "repository.h" #include "string-list.h" +#include "cache.h" struct commit; diff --git a/config.h b/config.h index bb2f506b27..75ba1d45ff 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,11 @@ #ifndef CONFIG_H #define CONFIG_H +#inclu
[PATCHv4 3/6] Move definition of enum branch_track from cache.h to branch.h
'branch_track' feels more closely related to branching, and it is needed later in branch.h; rather than #include'ing cache.h in branch.h for this small enum, just move the enum and the external declaration for git_branch_track to branch.h. Reviewed-by: Jonathan Nieder Signed-off-by: Elijah Newren --- branch.h | 11 +++ cache.h | 10 -- config.c | 1 + environment.c | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/branch.h b/branch.h index 7d9b330eba..5cace4581f 100644 --- a/branch.h +++ b/branch.h @@ -3,6 +3,17 @@ struct strbuf; +enum branch_track { + BRANCH_TRACK_UNSPECIFIED = -1, + BRANCH_TRACK_NEVER = 0, + BRANCH_TRACK_REMOTE, + BRANCH_TRACK_ALWAYS, + BRANCH_TRACK_EXPLICIT, + BRANCH_TRACK_OVERRIDE +}; + +extern enum branch_track git_branch_track; + /* Functions for acting on the information about branches. */ /* diff --git a/cache.h b/cache.h index 8dc7134f00..a1c0c594fb 100644 --- a/cache.h +++ b/cache.h @@ -919,15 +919,6 @@ enum log_refs_config { }; extern enum log_refs_config log_all_ref_updates; -enum branch_track { - BRANCH_TRACK_UNSPECIFIED = -1, - BRANCH_TRACK_NEVER = 0, - BRANCH_TRACK_REMOTE, - BRANCH_TRACK_ALWAYS, - BRANCH_TRACK_EXPLICIT, - BRANCH_TRACK_OVERRIDE -}; - enum rebase_setup_type { AUTOREBASE_NEVER = 0, AUTOREBASE_LOCAL, @@ -944,7 +935,6 @@ enum push_default_type { PUSH_DEFAULT_UNSPECIFIED }; -extern enum branch_track git_branch_track; extern enum rebase_setup_type autorebase; extern enum push_default_type push_default; diff --git a/config.c b/config.c index 66645047eb..66dca7978a 100644 --- a/config.c +++ b/config.c @@ -6,6 +6,7 @@ * */ #include "cache.h" +#include "branch.h" #include "config.h" #include "repository.h" #include "lockfile.h" diff --git a/environment.c b/environment.c index 6cf0079389..0c04a6da7a 100644 --- a/environment.c +++ b/environment.c @@ -8,6 +8,7 @@ * are. */ #include "cache.h" +#include "branch.h" #include "repository.h" #include "config.h" #include "refs.h" -- 2.18.0.553.g74975b7909
[PATCHv4 0/6] Add missing includes and forward declares
This series fixes compilation errors when using a simple test.c file that includes git-compat-util.h and then exactly one other header (and repeating this for different headers of git). Changes in this series come from Jonathan Nieder's reviews; full range-diff follows below, but in summary: - Squashed the final patch from the previous series into the first (Junio already applied a previous round and resolved the simple conflicts with next and pu, so making it easy to drop doesn't save effort anymore.) - Added a new patch to the series removing the forward declaration of an enum, for portability reasons. - Added Jonathan's Reviewed-by on the relevant patches - Remove a few includes and forward declares (which were initially added in previous rounds of this series) that are no longer necessary (due to other includes) - Fixed wording in commit message for patch 1 and added some comments about methodology used to come up with the patch. Elijah Newren (6): Add missing includes and forward declarations alloc: make allocate_alloc_state and clear_alloc_state more consistent Move definition of enum branch_track from cache.h to branch.h urlmatch.h: fix include guard compat/precompose_utf8.h: use more common include guard style Remove forward declaration of an enum alloc.c | 2 +- alloc.h | 4 +++- apply.h | 3 +++ archive.h| 1 + attr.h | 1 + bisect.h | 2 ++ branch.h | 13 + bulk-checkin.h | 2 ++ cache.h | 10 -- column.h | 1 + commit-graph.h | 1 + compat/precompose_utf8.h | 3 ++- config.c | 1 + config.h | 5 + connected.h | 1 + convert.h| 2 ++ csum-file.h | 2 ++ diffcore.h | 4 dir-iterator.h | 2 ++ environment.c| 1 + fsck.h | 1 + fsmonitor.h | 3 +++ gpg-interface.h | 2 ++ khash.h | 3 +++ list-objects-filter.h| 4 list-objects.h | 4 ll-merge.h | 2 ++ mailinfo.h | 2 ++ mailmap.h| 2 ++ merge-recursive.h| 4 +++- notes-merge.h| 4 notes-utils.h| 3 +++ notes.h | 3 +++ object-store.h | 1 + object.h | 2 ++ oidmap.h | 1 + pack-bitmap.h| 3 +++ pack-objects.h | 1 + packfile.h | 2 +- patch-ids.h | 6 ++ path.h | 1 + pathspec.h | 2 ++ pretty.h | 4 reachable.h | 2 ++ reflog-walk.h| 1 + refs.h | 2 ++ remote.h | 1 + repository.h | 2 ++ resolve-undo.h | 2 ++ revision.h | 1 + send-pack.h | 4 sequencer.h | 5 + shortlog.h | 2 ++ submodule.h | 10 -- tempfile.h | 1 + trailer.h| 2 ++ tree-walk.h | 2 ++ unpack-trees.h | 5 - url.h| 2 ++ urlmatch.h | 2 ++ utf8.h | 2 ++ worktree.h | 1 + 62 files changed, 152 insertions(+), 18 deletions(-) 1: f7d50cef3b ! 1: e6a93208b2 Add missing includes and forward declares @@ -1,6 +1,13 @@ Author: Elijah Newren -Add missing includes and forward declares +Add missing includes and forward declarations + +I looped over the toplevel header files, creating a temporary two-line C +program for each consisting of + #include "git-compat-util.h" + #include $HEADER +This patch is the result of manually fixing errors in compiling those +tiny programs. Signed-off-by: Elijah Newren @@ -38,15 +45,13 @@ --- a/archive.h +++ b/archive.h @@ + #ifndef ARCHIVE_H + #define ARCHIVE_H ++#include "cache.h" #include "pathspec.h" -+struct object_id; -+enum object_type; -+ struct archiver_args { - const char *base; - size_t baselen; diff --git a/attr.h b/attr.h --- a/attr.h @@ -60,6 +65,19 @@ /* * Given a string, return the gitattribute object that +diff --git a/bisect.h b/bisect.h +--- a/bisect.h b/bisect.h +@@ + #ifndef BISECT_H + #define BISECT_H + ++struct commit_list; ++ + /* + * Find bisection. If something is found, `reaches` will be the number of + * commits that the best commit reaches. `all` will be the count of + diff --git a/branch.h b/branch.h --- a/branch.h
[PATCHv4 2/6] alloc: make allocate_alloc_state and clear_alloc_state more consistent
Since both functions are using the same data type, they should either both refer to it as void *, or both use the real type (struct alloc_state *). Opt for the latter. Reviewed-by: Jonathan Nieder Signed-off-by: Elijah Newren --- alloc.c | 2 +- alloc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/alloc.c b/alloc.c index c2fc5d6888..e7aa81b7aa 100644 --- a/alloc.c +++ b/alloc.c @@ -36,7 +36,7 @@ struct alloc_state { int slab_nr, slab_alloc; }; -void *allocate_alloc_state(void) +struct alloc_state *allocate_alloc_state(void) { return xcalloc(1, sizeof(struct alloc_state)); } diff --git a/alloc.h b/alloc.h index 7a41bb9eb3..ba356ed847 100644 --- a/alloc.h +++ b/alloc.h @@ -15,7 +15,7 @@ void *alloc_object_node(struct repository *r); void alloc_report(struct repository *r); unsigned int alloc_commit_index(struct repository *r); -void *allocate_alloc_state(void); +struct alloc_state *allocate_alloc_state(void); void clear_alloc_state(struct alloc_state *s); #endif -- 2.18.0.553.g74975b7909
Re: [PATCH] Makefile: extend NO_TCLTK=NoThanks to cover docs
On Wed, Aug 15 2018, Junio C Hamano wrote: > Junio C Hamano writes: > >>> # Guard against environment variables >>> MAN1_TXT = >>> +MAN1_TXT_WIP = >>> +TCLTK_FILES = >> >> The latter name loses the fact that it is to hold candidates to be >> on MAN1_TXT that happen to be conditionally included; calling it >> MAN1_TXT_TCLTK or something, perhaps, may be an improvement. >> >> The former name makes it look it is work-in-progress, but in fact >> they are definite and unconditional part of MAN1_TXT. Perhaps >> MAN1_TXT_CORE or something? > > Sorry, I misread the patch. You collect all possible MAN1_TXT > candidates on _WIP, so "this is unconditional core part" is wrong. > Work-in-progress still sounds a bit funny, but now I know what is > going on a bit better, it has become at last understandable ;-) Yeah maybe it should be *_TMP. It's because you can't assign to a make variable twice (or rather, define a variable in terms of its previous value via filter). Otherwise I would just munge it in-place. >>> +ifndef NO_TCLTK >>> +MAN1_TXT_WIP += gitk.txt >>> +MAN1_TXT = $(MAN1_TXT_WIP) >>> +else >>> +TCLTK_FILES += git-gui.txt >>> +TCLTK_FILES += gitk.txt >>> +TCLTK_FILES += git-citool.txt >>> +MAN1_TXT = $(filter-out \ >>> + $(TCLTK_FILES), \ >>> + $(MAN1_TXT_WIP)) >>> +endif > > I didn't notice it when I read it for the first time, but asymmetry > between these two looks somewhat strange. If we are adding gitk.txt > when we are not declining TCLTK based programs, why can we do > without adding git-gui and git-citool at the same time? If we know > we must add gitk.txt when we are not declining TCLTK based programs > to MAN1_TXT_WIP in this section, it must mean that when we do not > want TCLTK based programs, MAN1_TXT_WIP would not have gitk.txt on > it, so why do we even need it on TCLTK_FILES list to filter it out? The only explicitly listed files are those that don't match the wildcard git-*.txt. Therefore if we want gitk.txt we need to explicitly list only it, but if we don't want the TCL programs we also need to list the ones that match git-*.txt.
Re: [PATCH] rebase -i: fix numbering in squash message
Phillip Wood writes: > From: Phillip Wood > > Commit e12a7ef597 ("rebase -i: Handle "combination of commits" with > GETTEXT_POISON", 2018-04-27) changed the way that individual commit > messages are labelled when squashing commits together. In doing so a > regression was introduced where the numbering of the messages is off by > one. This commit fixes that and adds a test for the numbering. > > Signed-off-by: Phillip Wood > --- > sequencer.c| 4 ++-- > t/t3418-rebase-continue.sh | 4 +++- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index 2eb5ec7227..77d3c2346f 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1387,13 +1387,13 @@ static int update_squash_messages(enum todo_command > command, > unlink(rebase_path_fixup_msg()); > strbuf_addf(&buf, "\n%c ", comment_line_char); > strbuf_addf(&buf, _("This is the commit message #%d:"), > - ++opts->current_fixup_count); > + ++opts->current_fixup_count + 1); > strbuf_addstr(&buf, "\n\n"); > strbuf_addstr(&buf, body); > } else if (command == TODO_FIXUP) { > strbuf_addf(&buf, "\n%c ", comment_line_char); > strbuf_addf(&buf, _("The commit message #%d will be skipped:"), > - ++opts->current_fixup_count); > + ++opts->current_fixup_count + 1); > strbuf_addstr(&buf, "\n\n"); > strbuf_add_commented_lines(&buf, body, strlen(body)); > } else Good spotting. When viewed in a wider context (e.g. "git show -W" after applying this patch), the way opts->current_fixup_count is used is somewhat incoherent and adding 1 to pre-increment would make it even more painful to read. Given that there already is strbuf_addf(&header, _("This is a combination of %d commits."), opts->current_fixup_count + 2); before this part, the code should make it clear these three places refer to the same number for it to be readable. I wonder if it makes it easier to read, understand and maintain if there were a local variable that gets opts->current_fixup_count+2 at the beginning of the function, make these three places refer to that variable, and move the increment of opts->current_fixup_count down in the function, after the "if we are squashing, do this, if we are fixing up, do that, otherwise, we do not know what we are doing" cascade. And use the more common post-increment, as we no longer depend on the returned value while at it. IOW, something like this (untested), on top of yours. sequencer.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index 77d3c2346f..f82c283a89 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1331,8 +1331,9 @@ static int update_squash_messages(enum todo_command command, struct strbuf buf = STRBUF_INIT; int res; const char *message, *body; + int fixup_count = opts->current_fixup_count + 2; - if (opts->current_fixup_count > 0) { + if (fixup_count > 2) { struct strbuf header = STRBUF_INIT; char *eol; @@ -1345,7 +1346,7 @@ static int update_squash_messages(enum todo_command command, strbuf_addf(&header, "%c ", comment_line_char); strbuf_addf(&header, _("This is a combination of %d commits."), - opts->current_fixup_count + 2); + fixup_count); strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len); strbuf_release(&header); } else { @@ -1387,18 +1388,19 @@ static int update_squash_messages(enum todo_command command, unlink(rebase_path_fixup_msg()); strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _("This is the commit message #%d:"), - ++opts->current_fixup_count + 1); + fixup_count); strbuf_addstr(&buf, "\n\n"); strbuf_addstr(&buf, body); } else if (command == TODO_FIXUP) { strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _("The commit message #%d will be skipped:"), - ++opts->current_fixup_count + 1); + fixup_count); strbuf_addstr(&buf, "\n\n"); strbuf_add_commented_lines(&buf, body, strlen(body)); } else return error(_("unknown command: %d"), command); unuse_commit_buffer(commit, message); + opts->current_fixup_count++; res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), 0); strbuf_release(&buf);
Re: [PATCH] Makefile: extend NO_TCLTK=NoThanks to cover docs
Ævar Arnfjörð Bjarmason writes: +ifndef NO_TCLTK +MAN1_TXT_WIP += gitk.txt +MAN1_TXT = $(MAN1_TXT_WIP) +else +TCLTK_FILES += git-gui.txt +TCLTK_FILES += gitk.txt +TCLTK_FILES += git-citool.txt +MAN1_TXT = $(filter-out \ + $(TCLTK_FILES), \ + $(MAN1_TXT_WIP)) +endif >> >> I didn't notice it when I read it for the first time, but asymmetry >> between these two looks somewhat strange. If we are adding gitk.txt >> when we are not declining TCLTK based programs, why can we do >> without adding git-gui and git-citool at the same time? If we know >> we must add gitk.txt when we are not declining TCLTK based programs >> to MAN1_TXT_WIP in this section, it must mean that when we do not >> want TCLTK based programs, MAN1_TXT_WIP would not have gitk.txt on >> it, so why do we even need it on TCLTK_FILES list to filter it out? > > The only explicitly listed files are those that don't match the wildcard > git-*.txt. Therefore if we want gitk.txt we need to explicitly list only > it, but if we don't want the TCL programs we also need to list the ones > that match git-*.txt. Which means that gitk.txt does not have to be on TCLTK_FILES list, no?
Re: [PATCH v4 2/5] unpack-trees: add performance tracing
Duy Nguyen writes: > On Tue, Aug 14, 2018 at 10:52 PM Junio C Hamano wrote: >> > It's not just sampling points. There's things like index id being >> > shown in the message for example. I prefer to keep free style format >> > to help me read. There's also things like indentation I do here to >> > help me read. >> >> Yup, I do not think that contradicts with the approach to have a >> single unified "data collection" API; you should also be able to >> specify how that collection of data is to be presented in the trace >> messages meant for humans, which would be discarded when emitting >> json but would be used when showing human-readble trace, no? > > Yes. As Peff also pointed out in another mail, as long as this > structured logging stuff does not stop me from manual trace messages > and don't force more work on me when I add new traces, I don't care if > it exists. I am hoping that we are on the same page, but just to make sure, what I think we would want is to have just a single set of annotations in the codepath, instead of "we can add annotations from these two separate sets, and they do not interfere each other so I do not care about what the other guy is doing". IOW, I found it highly annoying having to resolve merges like 7234f27b ("Merge branch 'nd/unpack-trees-with-cache-tree' into pu", 2018-08-14), taking two topics that try to use different tracing mechanisms in the same codepath.
Re: [PATCH] rebase -i: fix numbering in squash message
Hi Junio On 15/08/2018 19:05, Junio C Hamano wrote: > > Phillip Wood writes: > >> From: Phillip Wood >> >> Commit e12a7ef597 ("rebase -i: Handle "combination of commits" with >> GETTEXT_POISON", 2018-04-27) changed the way that individual commit >> messages are labelled when squashing commits together. In doing so a >> regression was introduced where the numbering of the messages is off by >> one. This commit fixes that and adds a test for the numbering. >> >> Signed-off-by: Phillip Wood >> --- >> sequencer.c| 4 ++-- >> t/t3418-rebase-continue.sh | 4 +++- >> 2 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/sequencer.c b/sequencer.c >> index 2eb5ec7227..77d3c2346f 100644 >> --- a/sequencer.c >> +++ b/sequencer.c >> @@ -1387,13 +1387,13 @@ static int update_squash_messages(enum todo_command >> command, >> unlink(rebase_path_fixup_msg()); >> strbuf_addf(&buf, "\n%c ", comment_line_char); >> strbuf_addf(&buf, _("This is the commit message #%d:"), >> -++opts->current_fixup_count); >> +++opts->current_fixup_count + 1); >> strbuf_addstr(&buf, "\n\n"); >> strbuf_addstr(&buf, body); >> } else if (command == TODO_FIXUP) { >> strbuf_addf(&buf, "\n%c ", comment_line_char); >> strbuf_addf(&buf, _("The commit message #%d will be skipped:"), >> -++opts->current_fixup_count); >> +++opts->current_fixup_count + 1); >> strbuf_addstr(&buf, "\n\n"); >> strbuf_add_commented_lines(&buf, body, strlen(body)); >> } else > > Good spotting. When viewed in a wider context (e.g. "git show -W" > after applying this patch), the way opts->current_fixup_count is > used is somewhat incoherent and adding 1 to pre-increment would make > it even more painful to read. Given that there already is > > strbuf_addf(&header, _("This is a combination of %d commits."), > opts->current_fixup_count + 2); > > before this part, the code should make it clear these three places > refer to the same number for it to be readable. > > I wonder if it makes it easier to read, understand and maintain if > there were a local variable that gets opts->current_fixup_count+2 at > the beginning of the function, make these three places refer to that > variable, and move the increment of opts->current_fixup_count down > in the function, after the "if we are squashing, do this, if we are > fixing up, do that, otherwise, we do not know what we are doing" > cascade. And use the more common post-increment, as we no longer > depend on the returned value while at it. > > IOW, something like this (untested), on top of yours. I think you'd need to change commit_staged_changes() as well as it relies on the current_fixup_count counting the number of fixups, not the number of fixups plus two. Having said that using 'current_fixup_count + 2' to create the labels and incrementing the count at the end of update_squash_messages() would probably be clearer than my version. I'm about to go away so it'll probably be the second week of September before I can re-roll this, will that be too late for getting it into 2.19? Best Wishes Phillip > > sequencer.c | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index 77d3c2346f..f82c283a89 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1331,8 +1331,9 @@ static int update_squash_messages(enum todo_command > command, > struct strbuf buf = STRBUF_INIT; > int res; > const char *message, *body; > + int fixup_count = opts->current_fixup_count + 2; > > - if (opts->current_fixup_count > 0) { > + if (fixup_count > 2) { > struct strbuf header = STRBUF_INIT; > char *eol; > > @@ -1345,7 +1346,7 @@ static int update_squash_messages(enum todo_command > command, > > strbuf_addf(&header, "%c ", comment_line_char); > strbuf_addf(&header, _("This is a combination of %d commits."), > - opts->current_fixup_count + 2); > + fixup_count); > strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len); > strbuf_release(&header); > } else { > @@ -1387,18 +1388,19 @@ static int update_squash_messages(enum todo_command > command, > unlink(rebase_path_fixup_msg()); > strbuf_addf(&buf, "\n%c ", comment_line_char); > strbuf_addf(&buf, _("This is the commit message #%d:"), > - ++opts->current_fixup_count + 1); > + fixup_count); > strbuf_addstr(&buf, "\n\n"); > strbuf_addstr(&buf, body); > } else if (command == TODO_FIXUP) { > strbuf_addf(&buf, "\n%c ", comment_line_char); >
[PATCH v3 1/6] chainlint: match arbitrary here-docs tags rather than hard-coded names
chainlint.sed swallows top-level here-docs to avoid being fooled by content which might look like start-of-subshell. It likewise swallows here-docs in subshells to avoid marking content lines as breaking the &&-chain, and to avoid being fooled by content which might look like end-of-subshell, start-of-nested-subshell, or other specially-recognized constructs. At the time of implementation, it was believed that it was not possible to support arbitrary here-doc tag names since 'sed' provides no way to stash the opening tag name in a variable for later comparison against a line signaling end-of-here-doc. Consequently, tag names are hard-coded, with "EOF" being the only tag recognized at the top-level, and only "EOF", "EOT", and "INPUT_END" being recognized within subshells. Also, special care was taken to avoid being confused by here-docs nested within other here-docs. In practice, this limited number of hard-coded tag names has been "good enough" for the 13000+ existing Git test, despite many of those tests using tags other than the recognized ones, since the bodies of those here-docs do not contain content which would fool the linter. Nevertheless, the situation is not ideal since someone writing new tests, and choosing a name not in the "blessed" set could potentially trigger a false-positive. To address this shortcoming, upgrade chainlint.sed to handle arbitrary here-doc tag names, both at the top-level and within subshells. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 57 +--- t/chainlint/here-doc.expect | 2 + t/chainlint/here-doc.test| 7 t/chainlint/nested-here-doc.expect | 2 + t/chainlint/nested-here-doc.test | 10 + t/chainlint/subshell-here-doc.expect | 4 ++ t/chainlint/subshell-here-doc.test | 8 7 files changed, 67 insertions(+), 23 deletions(-) diff --git a/t/chainlint.sed b/t/chainlint.sed index 5f0882cb38..2af1a687f8 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -61,6 +61,22 @@ # "else", and "fi" in if-then-else likewise must not end with "&&", thus # receives similar treatment. # +# Swallowing here-docs with arbitrary tags requires a bit of finesse. When a +# line such as "catout". +# As each subsequent line is read, it is appended to the target line and a +# (whitespace-loose) back-reference match /^<(.*)>\n\1$/ is attempted to see if +# the content inside "<...>" matches the entirety of the newly-read line. For +# instance, if the next line read is "some data", when concatenated with the +# target line, it becomes "cat >out\nsome data", and a match is attempted +# to see if "EOF" matches "some data". Since it doesn't, the next line is +# attempted. When a line consisting of only "EOF" (and possible whitespace) is +# encountered, it is appended to the target line giving "cat >out\nEOF", +# in which case the "EOF" inside "<...>" does match the text following the +# newline, thus the closing here-doc tag has been found. The closing tag line +# and the "<...>" prefix on the target line are then discarded, leaving just +# the target line "cat >out". +# # To facilitate regression testing (and manual debugging), a ">" annotation is # applied to the line containing ")" which closes a subshell, ">>" to a line # closing a nested subshell, and ">>>" to a line closing both at once. This @@ -78,14 +94,17 @@ # here-doc -- swallow it to avoid false hits within its body (but keep the # command to which it was attached) -/<<[ ]*[-\\]*EOF[]*/ { - s/[ ]*<<[ ]*[-\\]*EOF// - h +/<<[ ]*[-\\]*[A-Za-z0-9_]/ { + s/^\(.*\)<<[]*[-\\]*\([A-Za-z0-9_][A-Za-z0-9_]*\)/<\2>\1<]*\)>.*\n[ ]*\1[ ]*$/!{ + s/\n.*$// + bhereslurp + } + s/^<[^>]*>// + s/\n.*$// } # one-liner "(...) &&" @@ -139,9 +158,7 @@ s/.*\n// /"[^'"]*'[^'"]*"/!bsqstring } # here-doc -- swallow it -/<<[ ]*[-\\]*EOF/bheredoc -/<<[ ]*[-\\]*EOT/bheredoc -/<<[ ]*[-\\]*INPUT_END/bheredoc +/<<[ ]*[-\\]*[A-Za-z0-9_]/bheredoc # comment or empty line -- discard since final non-comment, non-empty line # before closing ")", "done", "elsif", "else", or "fi" will need to be # re-visited to drop "suspect" marking since final line of those constructs @@ -249,23 +266,17 @@ s/\n// bcheckchain # found here-doc -- swallow it to avoid false hits within its body (but keep -# the command to which it was attached); take care to handle here-docs nested -# within here-docs by only recognizing closing tag matching outer here-doc -# opening tag +# the command to which it was attached) :heredoc -/EOF/{ s/[ ]*<<[ ]*[-\\]*EOF//; s/^/EOF/; } -/EOT/{ s/[ ]*<<[ ]*[-\\]*EOT//; s/^/EOT/; } -/INPUT_END/{ s/[ ]*<<[ ]*[-\\]*INPUT_END//; s/^/INPUT_END/; } +s/^\(.*\)<<[ ]*[-\\]*\([A-Za-z0-9_][A-Za-z0-9_]*\)/<\2>\1
[PATCH v3 0/6] chainlint: improve robustness against "unusual" shell coding
This is a re-roll of [1] which improves chainlint's robustness in the face of unusual shell coding such as in contrib/subtree/t7900 which triggered a false-positive[2]. Changes since v2: * recognize "quoted" here-doc tag names (in addition to 'quoted' and \escaped) Interdiff below. [1]: https://public-inbox.org/git/20180813084739.16134-1-sunsh...@sunshineco.com/ [2]: https://public-inbox.org/git/20180730181356.ga156...@aiede.svl.corp.google.com/ Eric Sunshine (6): chainlint: match arbitrary here-docs tags rather than hard-coded names chainlint: match quoted here-doc tags chainlint: recognize multi-line $(...) when command cuddled with "$(" chainlint: let here-doc and multi-line string commence on same line chainlint: recognize multi-line quoted strings more robustly chainlint: add test of pathological case which triggered false positive t/chainlint.sed | 98 --- t/chainlint/here-doc-close-subshell.expect| 2 + t/chainlint/here-doc-close-subshell.test | 5 + .../here-doc-multi-line-command-subst.expect | 5 + .../here-doc-multi-line-command-subst.test| 9 ++ t/chainlint/here-doc-multi-line-string.expect | 4 + t/chainlint/here-doc-multi-line-string.test | 8 ++ t/chainlint/here-doc.expect | 6 ++ t/chainlint/here-doc.test | 21 ...ti-line-nested-command-substitution.expect | 11 ++- ...ulti-line-nested-command-substitution.test | 11 ++- t/chainlint/multi-line-string.expect | 10 +- t/chainlint/multi-line-string.test| 12 +++ t/chainlint/nested-here-doc.expect| 2 + t/chainlint/nested-here-doc.test | 10 ++ t/chainlint/subshell-here-doc.expect | 6 ++ t/chainlint/subshell-here-doc.test| 16 +++ t/chainlint/t7900-subtree.expect | 10 ++ t/chainlint/t7900-subtree.test| 22 + 19 files changed, 227 insertions(+), 41 deletions(-) create mode 100644 t/chainlint/here-doc-close-subshell.expect create mode 100644 t/chainlint/here-doc-close-subshell.test create mode 100644 t/chainlint/here-doc-multi-line-command-subst.expect create mode 100644 t/chainlint/here-doc-multi-line-command-subst.test create mode 100644 t/chainlint/here-doc-multi-line-string.expect create mode 100644 t/chainlint/here-doc-multi-line-string.test create mode 100644 t/chainlint/t7900-subtree.expect create mode 100644 t/chainlint/t7900-subtree.test Interdiff against v2: diff --git a/t/chainlint.sed b/t/chainlint.sed index 8544df38df..1da58b554b 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -94,8 +94,8 @@ # here-doc -- swallow it to avoid false hits within its body (but keep the # command to which it was attached) -/<<[ ]*[-\\']*[A-Za-z0-9_]/ { - s/^\(.*\)<<[]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<\1<\1<\1bar && +cat >boo && + horticulture diff --git a/t/chainlint/here-doc.test b/t/chainlint/here-doc.test index f2bb14b693..ad4ce8afd9 100644 --- a/t/chainlint/here-doc.test +++ b/t/chainlint/here-doc.test @@ -21,6 +21,13 @@ boz woz FUMP +# LINT: swallow "quoted" here-doc +cat <<"zump" >boo && +snoz +boz +woz +zump + # LINT: swallow here-doc (EOF is last line of test) horticulture <<\EOF gomez diff --git a/t/chainlint/subshell-here-doc.expect b/t/chainlint/subshell-here-doc.expect index 7663ea7fc4..74723e7340 100644 --- a/t/chainlint/subshell-here-doc.expect +++ b/t/chainlint/subshell-here-doc.expect @@ -6,5 +6,6 @@ ( cat >bup && cat >bup2 && + cat >bup3 && meep >) diff --git a/t/chainlint/subshell-here-doc.test b/t/chainlint/subshell-here-doc.test index b6b5a9b33a..f6b3ba4214 100644 --- a/t/chainlint/subshell-here-doc.test +++ b/t/chainlint/subshell-here-doc.test @@ -31,6 +31,9 @@ glink FIZZ ARBITRARY2 + cat <<-"ARBITRARY3" >bup3 && + glink + FIZZ + ARBITRARY3 meep ) -- 2.18.0.267.gbc8be36ecb
[PATCH v3 6/6] chainlint: add test of pathological case which triggered false positive
This extract from contrib/subtree/t7900 triggered a false positive due to three chainlint limitations: * recognizing only a "blessed" set of here-doc tag names in a subshell ("EOF", "EOT", "INPUT_END"), of which "TXT" is not a member * inability to recognize multi-line $(...) when the first statement of the body is cuddled with the opening "$(" * inability to recognize multiple constructs on a single line, such as opening a multi-line $(...) and starting a here-doc Now that all of these shortcomings have been addressed, turn this rather pathological bit of shell coding into a chainlint test case. Signed-off-by: Eric Sunshine --- t/chainlint/t7900-subtree.expect | 10 ++ t/chainlint/t7900-subtree.test | 22 ++ 2 files changed, 32 insertions(+) create mode 100644 t/chainlint/t7900-subtree.expect create mode 100644 t/chainlint/t7900-subtree.test diff --git a/t/chainlint/t7900-subtree.expect b/t/chainlint/t7900-subtree.expect new file mode 100644 index 00..c9913429e6 --- /dev/null +++ b/t/chainlint/t7900-subtree.expect @@ -0,0 +1,10 @@ +( + chks="sub1sub2sub3sub4" && + chks_sub=$(cat | sed 's,^,sub dir/,' +>>) && + chkms="main-sub1main-sub2main-sub3main-sub4" && + chkms_sub=$(cat | sed 's,^,sub dir/,' +>>) && + subfiles=$(git ls-files) && + check_equal "$subfiles" "$chkms$chks" +>) diff --git a/t/chainlint/t7900-subtree.test b/t/chainlint/t7900-subtree.test new file mode 100644 index 00..277d8358df --- /dev/null +++ b/t/chainlint/t7900-subtree.test @@ -0,0 +1,22 @@ +( + chks="sub1 +sub2 +sub3 +sub4" && + chks_sub=$(cat <
[PATCH v3 5/6] chainlint: recognize multi-line quoted strings more robustly
chainlint.sed recognizes multi-line quoted strings within subshells: echo "abc def" >out && so it can avoid incorrectly classifying lines internal to the string as breaking the &&-chain. To identify the first line of a multi-line string, it checks if the line contains a single quote. However, this is fragile and can be easily fooled by a line containing multiple strings: echo "xyz" "abc def" >out && Make detection more robust by checking for an odd number of quotes rather than only a single one. (Escaped quotes are not handled, but support may be added later.) The original multi-line string recognizer rather cavalierly threw away all but the final quote, whereas the new one is careful to retain all quotes, so the "expected" output of a couple existing chainlint tests is updated to account for this new behavior. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 32 +-- t/chainlint/here-doc-multi-line-string.expect | 2 +- t/chainlint/multi-line-string.expect | 10 -- t/chainlint/multi-line-string.test| 12 +++ 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/t/chainlint.sed b/t/chainlint.sed index 41cb6ef865..1da58b554b 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -151,10 +151,10 @@ s/.*\n// :slurp # incomplete line "...\" /\\$/bincomplete -# multi-line quoted string "...\n..." -/^[^"]*"[^"]*$/bdqstring -# multi-line quoted string '...\n...' (but not contraction in string "it's so") -/^[^']*'[^']*$/{ +# multi-line quoted string "...\n..."? +/"/bdqstring +# multi-line quoted string '...\n...'? (but not contraction in string "it's") +/'/{ /"[^'"]*'[^'"]*"/!bsqstring } :folded @@ -250,20 +250,32 @@ N s/\\\n// bslurp -# found multi-line double-quoted string "...\n..." -- slurp until end of string +# check for multi-line double-quoted string "...\n..." -- fold to one line :dqstring -s/"//g +# remove all quote pairs +s/"\([^"]*\)"/@!\1@!/g +# done if no dangling quote +/"/!bdqdone +# otherwise, slurp next line and try again N s/\n// -/"/!bdqstring +bdqstring +:dqdone +s/@!/"/g bfolded -# found multi-line single-quoted string '...\n...' -- slurp until end of string +# check for multi-line single-quoted string '...\n...' -- fold to one line :sqstring -s/'//g +# remove all quote pairs +s/'\([^']*\)'/@!\1@!/g +# done if no dangling quote +/'/!bsqdone +# otherwise, slurp next line and try again N s/\n// -/'/!bsqstring +bsqstring +:sqdone +s/@!/'/g bfolded # found here-doc -- swallow it to avoid false hits within its body (but keep diff --git a/t/chainlint/here-doc-multi-line-string.expect b/t/chainlint/here-doc-multi-line-string.expect index 1e5b724b9d..32038a070c 100644 --- a/t/chainlint/here-doc-multi-line-string.expect +++ b/t/chainlint/here-doc-multi-line-string.expect @@ -1,4 +1,4 @@ ( -?!AMP?!cat && echo multi-line string" +?!AMP?!cat && echo "multi-line string" bap >) diff --git a/t/chainlint/multi-line-string.expect b/t/chainlint/multi-line-string.expect index 8334c4cc8e..170cb59993 100644 --- a/t/chainlint/multi-line-string.expect +++ b/t/chainlint/multi-line-string.expect @@ -1,9 +1,15 @@ ( - x=line 1line 2 line 3" && -?!AMP?!y=line 1line2' + x="line 1 line 2 line 3" && +?!AMP?!y='line 1 line2' foobar >) && ( echo "there's nothing to see here" && exit +>) && +( + echo "xyz" "abc def ghi" && + echo 'xyz' 'abc def ghi' && + echo 'xyz' "abc def ghi" && + barfoo >) diff --git a/t/chainlint/multi-line-string.test b/t/chainlint/multi-line-string.test index 14cb44d51c..287ab89705 100644 --- a/t/chainlint/multi-line-string.test +++ b/t/chainlint/multi-line-string.test @@ -12,4 +12,16 @@ # LINT: starting multi-line single-quoted string echo "there's nothing to see here" && exit +) && +( + echo "xyz" "abc + def + ghi" && + echo 'xyz' 'abc + def + ghi' && + echo 'xyz' "abc + def + ghi" && + barfoo ) -- 2.18.0.267.gbc8be36ecb
[PATCH v3 2/6] chainlint: match quoted here-doc tags
A here-doc tag can be quoted ('EOF'/"EOF") or escaped (\EOF) to suppress interpolation within the body. Although, chainlint recognizes escaped tags, it does not know about quoted tags. For completeness, teach it to recognize quoted tags, as well. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 8 t/chainlint/here-doc.expect | 4 t/chainlint/here-doc.test| 14 ++ t/chainlint/subshell-here-doc.expect | 2 ++ t/chainlint/subshell-here-doc.test | 8 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/t/chainlint.sed b/t/chainlint.sed index 2af1a687f8..07c624fe09 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -94,8 +94,8 @@ # here-doc -- swallow it to avoid false hits within its body (but keep the # command to which it was attached) -/<<[ ]*[-\\]*[A-Za-z0-9_]/ { - s/^\(.*\)<<[]*[-\\]*\([A-Za-z0-9_][A-Za-z0-9_]*\)/<\2>\1<\1<\1<\1bar && + +cat >boo && + horticulture diff --git a/t/chainlint/here-doc.test b/t/chainlint/here-doc.test index 8986eefe74..ad4ce8afd9 100644 --- a/t/chainlint/here-doc.test +++ b/t/chainlint/here-doc.test @@ -14,6 +14,20 @@ boz woz Arbitrary_Tag_42 +# LINT: swallow 'quoted' here-doc +cat <<'FUMP' >bar && +snoz +boz +woz +FUMP + +# LINT: swallow "quoted" here-doc +cat <<"zump" >boo && +snoz +boz +woz +zump + # LINT: swallow here-doc (EOF is last line of test) horticulture <<\EOF gomez diff --git a/t/chainlint/subshell-here-doc.expect b/t/chainlint/subshell-here-doc.expect index 7c2da63bc7..74723e7340 100644 --- a/t/chainlint/subshell-here-doc.expect +++ b/t/chainlint/subshell-here-doc.expect @@ -5,5 +5,7 @@ >) && ( cat >bup && + cat >bup2 && + cat >bup3 && meep >) diff --git a/t/chainlint/subshell-here-doc.test b/t/chainlint/subshell-here-doc.test index 05139af0b5..f6b3ba4214 100644 --- a/t/chainlint/subshell-here-doc.test +++ b/t/chainlint/subshell-here-doc.test @@ -27,5 +27,13 @@ glink FIZZ ARBITRARY + cat <<-'ARBITRARY2' >bup2 && + glink + FIZZ + ARBITRARY2 + cat <<-"ARBITRARY3" >bup3 && + glink + FIZZ + ARBITRARY3 meep ) -- 2.18.0.267.gbc8be36ecb
[PATCH v3 3/6] chainlint: recognize multi-line $(...) when command cuddled with "$("
For multi-line $(...) expressions nested within subshells, chainlint.sed only recognizes: x=$( echo foo && ... but it is not unlikely that test authors may also cuddle the command with the opening "$(", so support that style, as well: x=$(echo foo && ... The closing ")" is already correctly recognized when cuddled or not. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 2 +- .../multi-line-nested-command-substitution.expect | 11 ++- .../multi-line-nested-command-substitution.test | 11 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/t/chainlint.sed b/t/chainlint.sed index 07c624fe09..a21c4b4d71 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -216,7 +216,7 @@ s/.*\n// # "$(...)" -- command substitution; not closing ")" /\$([^)][^)]*)[^)]*$/bcheckchain # multi-line "$(...\n...)" -- command substitution; treat as nested subshell -/\$([ ]*$/bnest +/\$([^)]*$/bnest # "=(...)" -- Bash array assignment; not closing ")" /=(/bcheckchain # closing "...) &&" diff --git a/t/chainlint/multi-line-nested-command-substitution.expect b/t/chainlint/multi-line-nested-command-substitution.expect index 19c023b1c8..59b6c8b850 100644 --- a/t/chainlint/multi-line-nested-command-substitution.expect +++ b/t/chainlint/multi-line-nested-command-substitution.expect @@ -6,4 +6,13 @@ >> ) && echo ok >) | -sort +sort && +( + bar && + x=$(echo bar | + cat +>> ) && + y=$(echo baz | +>> fip) && + echo fail +>) diff --git a/t/chainlint/multi-line-nested-command-substitution.test b/t/chainlint/multi-line-nested-command-substitution.test index ca0620ab6b..300058341b 100644 --- a/t/chainlint/multi-line-nested-command-substitution.test +++ b/t/chainlint/multi-line-nested-command-substitution.test @@ -6,4 +6,13 @@ ) && echo ok ) | -sort +sort && +( + bar && + x=$(echo bar | + cat + ) && + y=$(echo baz | + fip) && + echo fail +) -- 2.18.0.267.gbc8be36ecb
[PATCH v3 4/6] chainlint: let here-doc and multi-line string commence on same line
After swallowing a here-doc, chainlint.sed assumes that no other processing needs to be done on the line aside from checking for &&-chain breakage; likewise, after folding a multi-line quoted string. However, it's conceivable (even if unlikely in practice) that both a here-doc and a multi-line quoted string might commence on the same line: cat <<\EOF && echo "foo bar" data EOF Support this case by sending the line (after swallowing and folding) through the normal processing sequence rather than jumping directly to the check for broken &&-chain. This change also allows other somewhat pathological cases to be handled, such as closing a subshell on the same line starting a here-doc: ( cat <<-\INPUT) data INPUT or, for instance, opening a multi-line $(...) expression on the same line starting a here-doc: x=$(cat <<-\END && data END echo "x") among others. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 7 --- t/chainlint/here-doc-close-subshell.expect | 2 ++ t/chainlint/here-doc-close-subshell.test | 5 + t/chainlint/here-doc-multi-line-command-subst.expect | 5 + t/chainlint/here-doc-multi-line-command-subst.test | 9 + t/chainlint/here-doc-multi-line-string.expect| 4 t/chainlint/here-doc-multi-line-string.test | 8 7 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 t/chainlint/here-doc-close-subshell.expect create mode 100644 t/chainlint/here-doc-close-subshell.test create mode 100644 t/chainlint/here-doc-multi-line-command-subst.expect create mode 100644 t/chainlint/here-doc-multi-line-command-subst.test create mode 100644 t/chainlint/here-doc-multi-line-string.expect create mode 100644 t/chainlint/here-doc-multi-line-string.test diff --git a/t/chainlint.sed b/t/chainlint.sed index a21c4b4d71..41cb6ef865 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -157,6 +157,7 @@ s/.*\n// /^[^']*'[^']*$/{ /"[^'"]*'[^'"]*"/!bsqstring } +:folded # here-doc -- swallow it /<<[ ]*[-\\'"]*[A-Za-z0-9_]/bheredoc # comment or empty line -- discard since final non-comment, non-empty line @@ -255,7 +256,7 @@ s/"//g N s/\n// /"/!bdqstring -bcheckchain +bfolded # found multi-line single-quoted string '...\n...' -- slurp until end of string :sqstring @@ -263,7 +264,7 @@ s/'//g N s/\n// /'/!bsqstring -bcheckchain +bfolded # found here-doc -- swallow it to avoid false hits within its body (but keep # the command to which it was attached) @@ -278,7 +279,7 @@ N } s/^<[^>]*>// s/\n.*$// -bcheckchain +bfolded # found "case ... in" -- pass through untouched :case diff --git a/t/chainlint/here-doc-close-subshell.expect b/t/chainlint/here-doc-close-subshell.expect new file mode 100644 index 00..f011e335e5 --- /dev/null +++ b/t/chainlint/here-doc-close-subshell.expect @@ -0,0 +1,2 @@ +( +> cat) diff --git a/t/chainlint/here-doc-close-subshell.test b/t/chainlint/here-doc-close-subshell.test new file mode 100644 index 00..b857ff5467 --- /dev/null +++ b/t/chainlint/here-doc-close-subshell.test @@ -0,0 +1,5 @@ +( +# LINT: line contains here-doc and closes nested subshell + cat <<-\INPUT) + fizz + INPUT diff --git a/t/chainlint/here-doc-multi-line-command-subst.expect b/t/chainlint/here-doc-multi-line-command-subst.expect new file mode 100644 index 00..e5fb752d2f --- /dev/null +++ b/t/chainlint/here-doc-multi-line-command-subst.expect @@ -0,0 +1,5 @@ +( + x=$(bobble && +?!AMP?!>> wiffle) + echo $x +>) diff --git a/t/chainlint/here-doc-multi-line-command-subst.test b/t/chainlint/here-doc-multi-line-command-subst.test new file mode 100644 index 00..899bc5de8b --- /dev/null +++ b/t/chainlint/here-doc-multi-line-command-subst.test @@ -0,0 +1,9 @@ +( +# LINT: line contains here-doc and opens multi-line $(...) + x=$(bobble <<-\END && + fossil + vegetable + END + wiffle) + echo $x +) diff --git a/t/chainlint/here-doc-multi-line-string.expect b/t/chainlint/here-doc-multi-line-string.expect new file mode 100644 index 00..1e5b724b9d --- /dev/null +++ b/t/chainlint/here-doc-multi-line-string.expect @@ -0,0 +1,4 @@ +( +?!AMP?!cat && echo multi-line string" + bap +>) diff --git a/t/chainlint/here-doc-multi-line-string.test b/t/chainlint/here-doc-multi-line-string.test new file mode 100644 index 00..a53edbcc8d --- /dev/null +++ b/t/chainlint/here-doc-multi-line-string.test @@ -0,0 +1,8 @@ +( +# LINT: line contains here-doc and opens multi-line string + cat <<-\TXT && echo "multi-line + string" + fizzle + TXT + bap +) -- 2.18.0.267.gbc8be36ecb
Re: [PATCH 07/24] ls-files: correct index argument to get_convert_attr_ascii()
On Mon, Aug 13, 2018 at 9:15 AM Nguyễn Thái Ngọc Duy wrote: > > write_eolinfo() does take an istate as function argument and it should > be used instead of the_index. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > builtin/ls-files.c | 17 + > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/builtin/ls-files.c b/builtin/ls-files.c > index 7233b92794..7f9919a362 100644 > --- a/builtin/ls-files.c > +++ b/builtin/ls-files.c > @@ -63,7 +63,7 @@ static void write_eolinfo(const struct index_state *istate, > struct stat st; > const char *i_txt = ""; > const char *w_txt = ""; > - const char *a_txt = get_convert_attr_ascii(&the_index, path); > + const char *a_txt = get_convert_attr_ascii(istate, path); Going by the commit message this patch should end here? > -static void show_dir_entry(const char *tag, struct dir_entry *ent) > +static void show_dir_entry(const struct index_state *istate, > + const char *tag, struct dir_entry *ent) [...] > - if (!dir_path_match(&the_index, ent, &pathspec, len, ps_matched)) > + if (!dir_path_match(istate, ent, &pathspec, len, ps_matched)) [...] > - write_eolinfo(NULL, NULL, ent->name); > + write_eolinfo(istate, NULL, ent->name); but here we need to pass through the istate, which is why we adjust the dir_path_match while we're here > - show_dir_entry(tag_other, ent); > + show_dir_entry(istate, tag_other, ent); [...] > - show_dir_entry(tag_killed, dir->entries[i]); > + show_dir_entry(istate, tag_killed, dir->entries[i]); and having to adjust more callers here > @@ -228,7 +229,7 @@ static void show_ce(struct repository *repo, struct > dir_struct *dir, > - } else if (match_pathspec(&the_index, &pathspec, fullname, > strlen(fullname), > + } else if (match_pathspec(repo->index, &pathspec, fullname, > strlen(fullname), > @@ -264,7 +265,7 @@ static void show_ru_info(const struct index_state *istate) > - if (!match_pathspec(&the_index, &pathspec, path, len, > + if (!match_pathspec(istate, &pathspec, path, len, These seem more or less unrelated to the commit message or the code changes above. Maybe mention these as a "while at it" or separate them out in their own commit? thanks, Stefan
Re: [PATCH v4] clone: report duplicate entries on case-insensitive filesystems
On Sun, Aug 12, 2018 at 11:07:14AM +0200, Nguyễn Thái Ngọc Duy wrote: > Paths that only differ in case work fine in a case-sensitive > filesystems, but if those repos are cloned in a case-insensitive one, > you'll get problems. The first thing to notice is "git status" will > never be clean with no indication what exactly is "dirty". > > This patch helps the situation a bit by pointing out the problem at > clone time. Even though this patch talks about case sensitivity, the > patch makes no assumption about folding rules by the filesystem. It > simply observes that if an entry has been already checked out at clone > time when we're about to write a new path, some folding rules are > behind this. > > This patch is tested with vim-colorschemes repository on a JFS partition > with case insensitive support on Linux. This repository has two files > darkBlue.vim and darkblue.vim. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > v4 removes nr_duplicates (and fixes that false warning Szeder > reported). It also hints about case insensitivity as a cause of > problem because it's most likely the case when this warning shows up. > > builtin/clone.c | 1 + > cache.h | 1 + > entry.c | 28 > t/t5601-clone.sh | 8 +++- > unpack-trees.c | 28 > unpack-trees.h | 1 + > 6 files changed, 66 insertions(+), 1 deletion(-) > > diff --git a/builtin/clone.c b/builtin/clone.c > index 5c439f1394..0702b0e9d0 100644 > --- a/builtin/clone.c > +++ b/builtin/clone.c > @@ -747,6 +747,7 @@ static int checkout(int submodule_progress) > memset(&opts, 0, sizeof opts); > opts.update = 1; > opts.merge = 1; > + opts.clone = 1; > opts.fn = oneway_merge; > opts.verbose_update = (option_verbosity >= 0); > opts.src_index = &the_index; > diff --git a/cache.h b/cache.h > index 8b447652a7..6d6138f4f1 100644 > --- a/cache.h > +++ b/cache.h > @@ -1455,6 +1455,7 @@ struct checkout { > unsigned force:1, >quiet:1, >not_new:1, > + clone:1, >refresh_cache:1; > }; > #define CHECKOUT_INIT { NULL, "" } > diff --git a/entry.c b/entry.c > index b5d1d3cf23..c70340df8e 100644 > --- a/entry.c > +++ b/entry.c > @@ -399,6 +399,31 @@ static int check_path(const char *path, int len, struct > stat *st, int skiplen) > return lstat(path, st); > } > > +static void mark_colliding_entries(const struct checkout *state, > +struct cache_entry *ce, struct stat *st) > +{ > + int i; > + > + ce->ce_flags |= CE_MATCHED; > + > +#if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ > + for (i = 0; i < state->istate->cache_nr; i++) { > + struct cache_entry *dup = state->istate->cache[i]; > + > + if (dup == ce) > + break; > + > + if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE)) > + continue; > + Should the following be protected by core.checkstat ? if (check_stat) { > + if (dup->ce_stat_data.sd_ino == st->st_ino) { > + dup->ce_flags |= CE_MATCHED; > + break; > + } > + } > +#endif Another thing is that we switch of the ASCII case-folding-detection-logic off for Windows users, even if we otherwise rely on icase. I think we can use fspathcmp() as a fallback. when inodes fail, because we may be on a network file system. (I don't have a test setup at the moment, but what happens with inodes when a Windows machine exports a share to Linux or Mac ?) Is there a chance to get the fspathcmp() back, like this ? static void mark_colliding_entries(const struct checkout *state, struct cache_entry *ce, struct stat *st) { int i; ce->ce_flags |= CE_MATCHED; for (i = 0; i < state->istate->cache_nr; i++) { struct cache_entry *dup = state->istate->cache[i]; int folded = 0; if (dup == ce) break; if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE)) continue; if (!fspathcmp(dup->name, ce->name)) folded = 1; #if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ if (check_stat && (dup->ce_stat_data.sd_ino == st->st_ino)) folded = 1; #endif if (folded) { dup->ce_flags |= CE_MATCHED; break; } } }
Re: [PATCH 08/24] unpack-trees: remove 'extern' on function declaration
On Mon, Aug 13, 2018 at 9:15 AM Nguyễn Thái Ngọc Duy wrote: > > Signed-off-by: Nguyễn Thái Ngọc Duy This removes the only existing extern keyword, which was added by Linus in 933bf40a5c6 (Start moving unpack-trees to "struct tree_desc", 2007-08-09). All other callers do not have this noise word as it was simply never present there despite the old age of unpack-trees.h. Interesting history. Thanks! Stefan
Re: [PATCH] rebase -i: fix numbering in squash message
Phillip Wood writes: >> I wonder if it makes it easier to read, understand and maintain if >> there were a local variable that gets opts->current_fixup_count+2 at >> the beginning of the function, make these three places refer to that >> variable, and move the increment of opts->current_fixup_count down >> in the function, after the "if we are squashing, do this, if we are >> fixing up, do that, otherwise, we do not know what we are doing" >> cascade. And use the more common post-increment, as we no longer >> depend on the returned value while at it. >> >> IOW, something like this (untested), on top of yours. > > I think you'd need to change commit_staged_changes() as well as it > relies on the current_fixup_count counting the number of fixups, not the > number of fixups plus two. I suspect you misread what I wrote (see below for the patch). The fixup_count is a new local variable in update_squash_messages() that holds N+2; in other words, I am not suggesting to change what opts->current_fixup_count means. > Having said that using 'current_fixup_count + > 2' to create the labels and incrementing the count at the end of > update_squash_messages() would probably be clearer than my version. I'm > about to go away so it'll probably be the second week of September > before I can re-roll this, will that be too late for getting it into 2.19? I actually do not mind to go with what you originally sent, unless a cleaned up version is vastly more readable. After all, a clean-up can be done separately and safely. Thanks. >> sequencer.c | 10 ++ >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/sequencer.c b/sequencer.c >> index 77d3c2346f..f82c283a89 100644 >> --- a/sequencer.c >> +++ b/sequencer.c >> @@ -1331,8 +1331,9 @@ static int update_squash_messages(enum todo_command >> command, >> struct strbuf buf = STRBUF_INIT; >> int res; >> const char *message, *body; >> +int fixup_count = opts->current_fixup_count + 2; >> >> -if (opts->current_fixup_count > 0) { >> +if (fixup_count > 2) { >> struct strbuf header = STRBUF_INIT; >> char *eol; >> >> @@ -1345,7 +1346,7 @@ static int update_squash_messages(enum todo_command >> command, >> >> strbuf_addf(&header, "%c ", comment_line_char); >> strbuf_addf(&header, _("This is a combination of %d commits."), >> -opts->current_fixup_count + 2); >> +fixup_count); >> strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len); >> strbuf_release(&header); >> } else { >> @@ -1387,18 +1388,19 @@ static int update_squash_messages(enum todo_command >> command, >> unlink(rebase_path_fixup_msg()); >> strbuf_addf(&buf, "\n%c ", comment_line_char); >> strbuf_addf(&buf, _("This is the commit message #%d:"), >> -++opts->current_fixup_count + 1); >> +fixup_count); >> strbuf_addstr(&buf, "\n\n"); >> strbuf_addstr(&buf, body); >> } else if (command == TODO_FIXUP) { >> strbuf_addf(&buf, "\n%c ", comment_line_char); >> strbuf_addf(&buf, _("The commit message #%d will be skipped:"), >> -++opts->current_fixup_count + 1); >> +fixup_count); >> strbuf_addstr(&buf, "\n\n"); >> strbuf_add_commented_lines(&buf, body, strlen(body)); >> } else >> return error(_("unknown command: %d"), command); >> unuse_commit_buffer(commit, message); >> +opts->current_fixup_count++; >> >> res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), 0); >> strbuf_release(&buf); >> >>
Re: [PATCH 08/24] unpack-trees: remove 'extern' on function declaration
On Wed, Aug 15, 2018 at 9:10 PM Stefan Beller wrote: > > On Mon, Aug 13, 2018 at 9:15 AM Nguyễn Thái Ngọc Duy > wrote: > > > > Signed-off-by: Nguyễn Thái Ngọc Duy > > This removes the only existing extern keyword, which was added by > Linus in 933bf40a5c6 (Start moving unpack-trees to "struct tree_desc", > 2007-08-09). All other callers do not have this noise word as it was > simply never > present there despite the old age of unpack-trees.h. Interesting history. Linus did not add 'extern' though. It was Johannes a year ago in 16da134b1f (read-trees: refactor the unpack_trees() part - 2006-07-30). Man this function is _old_. -- Duy
Re: [PATCH 08/24] unpack-trees: remove 'extern' on function declaration
On Wed, Aug 15, 2018 at 12:21 PM Duy Nguyen wrote: > > On Wed, Aug 15, 2018 at 9:10 PM Stefan Beller wrote: > > > > On Mon, Aug 13, 2018 at 9:15 AM Nguyễn Thái Ngọc Duy > > wrote: > > > > > > Signed-off-by: Nguyễn Thái Ngọc Duy > > > > This removes the only existing extern keyword, which was added by > > Linus in 933bf40a5c6 (Start moving unpack-trees to "struct tree_desc", > > 2007-08-09). All other callers do not have this noise word as it was > > simply never > > present there despite the old age of unpack-trees.h. Interesting history. > > Linus did not add 'extern' though. It was Johannes a year ago in > 16da134b1f (read-trees: refactor the unpack_trees() part - > 2006-07-30). Man this function is _old_. Ah, yes. I stopped at the first blame here but dug down on other functions as I expected some of the recent "remove externs here" and magically overlook this function.
Re: [GSoC][PATCH v7 04/26] stash: renamed test cases to be more descriptive
> Subject: Re: [GSoC][PATCH v7 04/26] stash: renamed test cases to be more > descriptive Please use the imperative mood in the title and the commit messages themselves. From Documentation/SubmittingPatches: Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior. >From a quick skim over the rest of the series, this also applies to some of the subsequent patches in the series. On 08/08, Paul-Sebastian Ungureanu wrote: > Renamed some test cases' labels to be more descriptive and under 80 > characters per line. > > Signed-off-by: Paul-Sebastian Ungureanu > --- > t/t3903-stash.sh | 14 +++--- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh > index de6cab1fe..8d002a7f2 100755 > --- a/t/t3903-stash.sh > +++ b/t/t3903-stash.sh > @@ -604,7 +604,7 @@ test_expect_success 'stash show -p - no stashes on stack, > stash-like argument' ' > test_cmp expected actual > ' > > -test_expect_success 'stash drop - fail early if specified stash is not a > stash reference' ' > +test_expect_success 'drop: fail early if specified stash is not a stash ref' > ' > git stash clear && > test_when_finished "git reset --hard HEAD && git stash clear" && > git reset --hard && > @@ -618,7 +618,7 @@ test_expect_success 'stash drop - fail early if specified > stash is not a stash r > git reset --hard HEAD > ' > > -test_expect_success 'stash pop - fail early if specified stash is not a > stash reference' ' > +test_expect_success 'pop: fail early if specified stash is not a stash ref' ' > git stash clear && > test_when_finished "git reset --hard HEAD && git stash clear" && > git reset --hard && > @@ -682,7 +682,7 @@ test_expect_success 'invalid ref of the form "n", n >= N' > ' > git stash drop > ' > > -test_expect_success 'stash branch should not drop the stash if the branch > exists' ' > +test_expect_success 'branch: should not drop the stash if the branch exists' > ' Since we're adjusting the titles of the tests here I'll allow myself to nitpick a little :) Maybe "branch: do not drop the stash if the branch exists", which sounds more like an assertion, as the "pop" and "drop" titles above. > git stash clear && > echo foo >file && > git add file && > @@ -693,7 +693,7 @@ test_expect_success 'stash branch should not drop the > stash if the branch exists > git rev-parse stash@{0} -- > ' > > -test_expect_success 'stash branch should not drop the stash if the apply > fails' ' > +test_expect_success 'branch: should not drop the stash if the apply fails' ' > git stash clear && > git reset HEAD~1 --hard && > echo foo >file && > @@ -707,7 +707,7 @@ test_expect_success 'stash branch should not drop the > stash if the apply fails' > git rev-parse stash@{0} -- > ' > > -test_expect_success 'stash apply shows status same as git status (relative > to current directory)' ' > +test_expect_success 'apply: shows same status as git status (relative to > ./)' ' s/shows/show/ above maybe? This used to be a full sentence previously, where 'shows' was appropriate, but I think "show" sounds better after the colon. > git stash clear && > echo 1 >subdir/subfile1 && > echo 2 >subdir/subfile2 && > @@ -1048,7 +1048,7 @@ test_expect_success 'stash push -p with pathspec shows > no changes only once' ' > test_i18ncmp expect actual > ' > > -test_expect_success 'stash push with pathspec shows no changes when there > are none' ' > +test_expect_success 'push: shows no changes when there are none' ' Maybe "push : show no changes when there are none"? "push " would be the rest of the 'git stash' command, having the colon in between them seems a bit odd. > >foo && > git add foo && > git commit -m "tmp" && > @@ -1058,7 +1058,7 @@ test_expect_success 'stash push with pathspec shows no > changes when there are no > test_i18ncmp expect actual > ' > > -test_expect_success 'stash push with pathspec not in the repository errors > out' ' > +test_expect_success 'push: not in the repository errors out' ' This one makes sense to me. > >untracked && > test_must_fail git stash push untracked && > test_path_is_file untracked > -- > 2.18.0.573.g56500d98f >
Re: [PATCH v4] clone: report duplicate entries on case-insensitive filesystems
On Wed, Aug 15, 2018 at 9:08 PM Torsten Bögershausen wrote: > > +#if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ > > + for (i = 0; i < state->istate->cache_nr; i++) { > > + struct cache_entry *dup = state->istate->cache[i]; > > + > > + if (dup == ce) > > + break; > > + > > + if (dup->ce_flags & (CE_MATCHED | CE_VALID | > > CE_SKIP_WORKTREE)) > > + continue; > > + > > Should the following be protected by core.checkstat ? > if (check_stat) { Good catch! st_ino is ignored if core.checkStat is false. I will probably send a separate patch to add more details to config.txt about this key. > > + if (dup->ce_stat_data.sd_ino == st->st_ino) { > > + dup->ce_flags |= CE_MATCHED; > > + break; > > + } > > + } > > +#endif > > Another thing is that we switch of the ASCII case-folding-detection-logic > off for Windows users, even if we otherwise rely on icase. > I think we can use fspathcmp() as a fallback. when inodes fail, > because we may be on a network file system. I admit I did not think about network file system. Will spend some time (and hopefully not on nfs kernel code) on it. For falling back on fspathcmp even on Windows, is it really safe? I'm on Linux and never have to deal with this issue to have any experience. It does sound good though because it should be a subset for any "weird" filesystems out there. > (I don't have a test setup at the moment, but what happens with inodes > when a Windows machine exports a share to Linux or Mac ?) > > Is there a chance to get the fspathcmp() back, like this ? > > static void mark_colliding_entries(const struct checkout *state, >struct cache_entry *ce, struct stat *st) > { > int i; > ce->ce_flags |= CE_MATCHED; > > for (i = 0; i < state->istate->cache_nr; i++) { > struct cache_entry *dup = state->istate->cache[i]; > int folded = 0; > > if (dup == ce) > break; > > if (dup->ce_flags & (CE_MATCHED | CE_VALID | > CE_SKIP_WORKTREE)) > continue; > > if (!fspathcmp(dup->name, ce->name)) > folded = 1; > > #if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ > if (check_stat && (dup->ce_stat_data.sd_ino == st->st_ino)) > folded = 1; > #endif > if (folded) { > dup->ce_flags |= CE_MATCHED; > break; > } > } > } > -- Duy
Re: [PATCH v4] clone: report duplicate entries on case-insensitive filesystems
Torsten Bögershausen writes: >> + >> +#if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ >> +for (i = 0; i < state->istate->cache_nr; i++) { >> +struct cache_entry *dup = state->istate->cache[i]; >> + >> +if (dup == ce) >> +break; >> + >> +if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE)) >> +continue; >> + > > Should the following be protected by core.checkstat ? > if (check_stat) { I do not think such a if statement is strictly necessary. Even if check_stat tells us "when checking if a cached stat information tells us that the path may have modified, use minimum set of fields from the 'struct stat'", we still capture and update the values from the same "full" set of fields when we mark a cache entry up-to-date. So it all depends on why you are limiting with check_stat. Is it because stdev is unusable? Is it because nsec is unusable? Is it because ino is unusable? Only in the last case, paying attention to check_stat will reduce the false positive. But then you made me wonder what value check_stat has on Windows. If it is false, perhaps we do not even need the conditional compilation, which is a huge plus. >> +if (dup->ce_stat_data.sd_ino == st->st_ino) { >> +dup->ce_flags |= CE_MATCHED; >> +break; >> +} >> +} >> +#endif > > Another thing is that we switch of the ASCII case-folding-detection-logic > off for Windows users, even if we otherwise rely on icase. > I think we can use fspathcmp() as a fallback. when inodes fail, > because we may be on a network file system. > > (I don't have a test setup at the moment, but what happens with inodes > when a Windows machine exports a share to Linux or Mac ?) > > Is there a chance to get the fspathcmp() back, like this ? If fspathcmp() never gives false positives, I do not think we would mind using it like your update. False negatives are fine, as that is better than just punting the whole thing when there is no usable inum. And we do not care all that much if it is more expensive; this is an error codepath after all. And from code structure's point of view, I think it makes sense. It would be even better if we can lose the conditional compilation. Another thing we maybe want to see is if we can update the caller of this function so that we do not overwrite the earlier checkout with the data for this path. When two paths collide, we check out one of the paths without reporting (because we cannot notice), then attempt to check out the other path and report (because we do notice the previous one with lstat()). The current code then goes on and overwrites the file with the contents from the "other" path. Even if we had false negative in this loop, if we leave the contents for the earlier path while reporting the "other" path, then the user can get curious, inspect what contents the "other" path has on the filesystem, and can notice that it belongs to the (unreported--due to false negative) earlier path. > static void mark_colliding_entries(const struct checkout *state, > struct cache_entry *ce, struct stat *st) > { > int i; > ce->ce_flags |= CE_MATCHED; > > for (i = 0; i < state->istate->cache_nr; i++) { > struct cache_entry *dup = state->istate->cache[i]; > int folded = 0; > > if (dup == ce) > break; > > if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE)) > continue; > > if (!fspathcmp(dup->name, ce->name)) > folded = 1; > > #if !defined(GIT_WINDOWS_NATIVE) /* inode is always zero on Windows */ > if (check_stat && (dup->ce_stat_data.sd_ino == st->st_ino)) > folded = 1; > #endif > if (folded) { > dup->ce_flags |= CE_MATCHED; > break; > } > } > }
Re: [GSoC][PATCH v7 09/26] stash: implement the "list" command in the builtin
> Subject: stash: implement the "list" command in the builtin Nit: The previous commit messages all have the format "stash: convert to builtin", maybe follow the same pattern here? The rest of the patch looks good to me. On 08/08, Paul-Sebastian Ungureanu wrote: > Add stash list to the helper and delete the list_stash function > from the shell script. > > Signed-off-by: Paul-Sebastian Ungureanu > --- > builtin/stash--helper.c | 31 +++ > git-stash.sh| 7 +-- > 2 files changed, 32 insertions(+), 6 deletions(-) > > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index d6bd468e0..daa4d0034 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -12,6 +12,7 @@ > #include "rerere.h" > > static const char * const git_stash_helper_usage[] = { > + N_("git stash--helper list []"), > N_("git stash--helper drop [-q|--quiet] []"), > N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] > []"), > N_("git stash--helper branch []"), > @@ -19,6 +20,11 @@ static const char * const git_stash_helper_usage[] = { > NULL > }; > > +static const char * const git_stash_helper_list_usage[] = { > + N_("git stash--helper list []"), > + NULL > +}; > + > static const char * const git_stash_helper_drop_usage[] = { > N_("git stash--helper drop [-q|--quiet] []"), > NULL > @@ -609,6 +615,29 @@ static int branch_stash(int argc, const char **argv, > const char *prefix) > return ret; > } > > +static int list_stash(int argc, const char **argv, const char *prefix) > +{ > + struct child_process cp = CHILD_PROCESS_INIT; > + struct option options[] = { > + OPT_END() > + }; > + > + argc = parse_options(argc, argv, prefix, options, > + git_stash_helper_list_usage, > + PARSE_OPT_KEEP_UNKNOWN); > + > + if (!ref_exists(ref_stash)) > + return 0; > + > + cp.git_cmd = 1; > + argv_array_pushl(&cp.args, "log", "--format=%gd: %gs", "-g", > + "--first-parent", "-m", NULL); > + argv_array_pushv(&cp.args, argv); > + argv_array_push(&cp.args, ref_stash); > + argv_array_push(&cp.args, "--"); > + return run_command(&cp); > +} > + > int cmd_stash__helper(int argc, const char **argv, const char *prefix) > { > pid_t pid = getpid(); > @@ -639,6 +668,8 @@ int cmd_stash__helper(int argc, const char **argv, const > char *prefix) > return !!pop_stash(argc, argv, prefix); > else if (!strcmp(argv[0], "branch")) > return !!branch_stash(argc, argv, prefix); > + else if (!strcmp(argv[0], "list")) > + return !!list_stash(argc, argv, prefix); > > usage_msg_opt(xstrfmt(_("unknown subcommand: %s"), argv[0]), > git_stash_helper_usage, options); > diff --git a/git-stash.sh b/git-stash.sh > index 8f2640fe9..6052441aa 100755 > --- a/git-stash.sh > +++ b/git-stash.sh > @@ -382,11 +382,6 @@ have_stash () { > git rev-parse --verify --quiet $ref_stash >/dev/null > } > > -list_stash () { > - have_stash || return 0 > - git log --format="%gd: %gs" -g --first-parent -m "$@" $ref_stash -- > -} > - > show_stash () { > ALLOW_UNKNOWN_FLAGS=t > assert_stash_like "$@" > @@ -574,7 +569,7 @@ test -n "$seen_non_option" || set "push" "$@" > case "$1" in > list) > shift > - list_stash "$@" > + git stash--helper list "$@" > ;; > show) > shift > -- > 2.18.0.573.g56500d98f >
Re: [PATCH 00/24] Kill the_index part3
On Mon, Aug 13, 2018 at 2:24 PM Junio C Hamano wrote: > > Brandon Williams writes: > > > On 08/13, Nguyễn Thái Ngọc Duy wrote: > >> This is the third part of killing the_index (at least outside > >> builtin/). Part 1 [1] is dropped. Part 2 is nd/no-extern on 'pu'. This > >> part is built on top of nd/no-extern. > >> > >> This series would actually break 'pu' because builtin/stash.c uses > >> three functions that are updated here. So we would need something like > >> the following patch to make it build again. > >> > >> I don't know if that adds too much work on Junio. If it does, I guess > >> I'll hold this off for a while until builtin/stash.c gets merged > >> because reordering these patches, pushing the patches that break > >> stash.c away, really takes a lot of work. > >> > >> [1] https://public-inbox.org/git/20180616054157.32433-1-pclo...@gmail.com/ > > > > I went through and found this to be a pleasant read and hopefully others > > agree with the approach this series took vs what your part 1 did so that > > we can get this change in. > > Yeah, I've only finished my first pass (read: I didn't go through > the patches with fine toothed comb, nor thought about interactions > with other topics), but this round was quite a pleasnt read so far. > I went through this topic with a finer comb and just found nits, none of which I would deem a complete show stopper.
Re: [GSoC][PATCH v7 10/26] stash: convert show to builtin
On 08/08, Paul-Sebastian Ungureanu wrote: > Add stash show to the helper and delete the show_stash, have_stash, > assert_stash_like, is_stash_like and parse_flags_and_rev functions > from the shell script now that they are no longer needed. > > Before this commit, `git stash show` would ignore `--index` and > `--quiet` options. Now, `git stash show` errors out on `--index` > and does not display any message on `--quiet`, but errors out > if the stash is not empty. I think "errors out" is slightly misleading here. Maybe "but exits with an exit code similar to 'git diff'" instead? Looking at why we ignored them before, it's because we filtered them out in 'parse_flags_and_rev', which looks more accidental than intentional, and I think we could consider a bug, so this change in behaviour here is okay. '--quiet' doesn't make too much sense to use with 'git stash show', so I'm not sure whether or not it makes sense to support it at all. But we do promise to pass all options through to in our documentation, so the new behaviour is what we are documenting. > Signed-off-by: Paul-Sebastian Ungureanu > --- > builtin/stash--helper.c | 78 > git-stash.sh| 132 +--- > 2 files changed, 79 insertions(+), 131 deletions(-) > > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index daa4d0034..e764cd33e 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -13,6 +13,7 @@ > > static const char * const git_stash_helper_usage[] = { > N_("git stash--helper list []"), > + N_("git stash--helper show []"), > N_("git stash--helper drop [-q|--quiet] []"), > N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] > []"), > N_("git stash--helper branch []"), > @@ -25,6 +26,11 @@ static const char * const git_stash_helper_list_usage[] = { > NULL > }; > > +static const char * const git_stash_helper_show_usage[] = { > + N_("git stash--helper show []"), > + NULL > +}; > + > static const char * const git_stash_helper_drop_usage[] = { > N_("git stash--helper drop [-q|--quiet] []"), > NULL > @@ -638,6 +644,76 @@ static int list_stash(int argc, const char **argv, const > char *prefix) > return run_command(&cp); > } > > +static int show_stat = 1; > +static int show_patch; > + > +static int git_stash_config(const char *var, const char *value, void *cb) > +{ > + if (!strcmp(var, "stash.showStat")) { > + show_stat = git_config_bool(var, value); > + return 0; > + } > + if (!strcmp(var, "stash.showPatch")) { > + show_patch = git_config_bool(var, value); > + return 0; > + } > + return git_default_config(var, value, cb); > +} > + > +static int show_stash(int argc, const char **argv, const char *prefix) > +{ > + int i, ret = 0; > + struct child_process cp = CHILD_PROCESS_INIT; > + struct argv_array args_refs = ARGV_ARRAY_INIT; > + struct stash_info info; > + struct option options[] = { > + OPT_END() > + }; > + > + argc = parse_options(argc, argv, prefix, options, > + git_stash_helper_show_usage, > + PARSE_OPT_KEEP_UNKNOWN); > + > + cp.git_cmd = 1; > + argv_array_push(&cp.args, "diff"); > + > + /* Push arguments which are not options into args_refs. */ > + for (i = 0; i < argc; ++i) { > + if (argv[i][0] == '-') > + argv_array_push(&cp.args, argv[i]); > + else > + argv_array_push(&args_refs, argv[i]); > + } > + > + if (get_stash_info(&info, args_refs.argc, args_refs.argv)) { > + child_process_clear(&cp); > + argv_array_clear(&args_refs); > + return -1; > + } > + > + /* > + * The config settings are applied only if there are not passed > + * any flags. > + */ > + if (cp.args.argc == 1) { > + git_config(git_stash_config, NULL); > + if (show_stat) > + argv_array_push(&cp.args, "--stat"); > + > + if (show_patch) > + argv_array_push(&cp.args, "-p"); > + } > + > + argv_array_pushl(&cp.args, oid_to_hex(&info.b_commit), > + oid_to_hex(&info.w_commit), NULL); > + > + ret = run_command(&cp); > + > + free_stash_info(&info); > + argv_array_clear(&args_refs); > + return ret; > +} > + > int cmd_stash__helper(int argc, const char **argv, const char *prefix) > { > pid_t pid = getpid(); > @@ -670,6 +746,8 @@ int cmd_stash__helper(int argc, const char **argv, const > char *prefix) > return !!branch_stash(argc, argv, prefix); > else if (!strcmp(argv[0], "list")) > return !!list_stash(argc, argv, prefix); > + else if (!strcmp(argv[0], "show")) > + return !!show_stash(argc, argv, prefix); > >
Re: [GSoC][PATCH v7 11/26] stash: change `git stash show` usage text and documentation
> Subject: stash: change `git stash show` usage text and documentation Another nitpick about commit messages. "change ... usage text and documentation" doesn't say much about what the actual change is. How about something like "stash: mention options in "show" synopsis" instead? The change itself looks good to me, thanks! On 08/08, Paul-Sebastian Ungureanu wrote: > It is already stated in documentation that it will accept any > option known to `git diff`, but not in the usage text and some > parts of the documentation. > > Signed-off-by: Paul-Sebastian Ungureanu > --- > Documentation/git-stash.txt | 4 ++-- > builtin/stash--helper.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt > index 7ef8c4791..e31ea7d30 100644 > --- a/Documentation/git-stash.txt > +++ b/Documentation/git-stash.txt > @@ -9,7 +9,7 @@ SYNOPSIS > > [verse] > 'git stash' list [] > -'git stash' show [] > +'git stash' show [] [] > 'git stash' drop [-q|--quiet] [] > 'git stash' ( pop | apply ) [--index] [-q|--quiet] [] > 'git stash' branch [] > @@ -106,7 +106,7 @@ stash@{1}: On master: 9cc0589... Add git-stash > The command takes options applicable to the 'git log' > command to control what is shown and how. See linkgit:git-log[1]. > > -show []:: > +show [] []:: > > Show the changes recorded in the stash entry as a diff between the > stashed contents and the commit back when the stash entry was first > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index e764cd33e..0c1efca6b 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -13,7 +13,7 @@ > > static const char * const git_stash_helper_usage[] = { > N_("git stash--helper list []"), > - N_("git stash--helper show []"), > + N_("git stash--helper show [] []"), > N_("git stash--helper drop [-q|--quiet] []"), > N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] > []"), > N_("git stash--helper branch []"), > @@ -27,7 +27,7 @@ static const char * const git_stash_helper_list_usage[] = { > }; > > static const char * const git_stash_helper_show_usage[] = { > - N_("git stash--helper show []"), > + N_("git stash--helper show [] []"), > NULL > }; > > -- > 2.18.0.573.g56500d98f >
"less -F" is broken
Sadly, as of less-530, the behavior of "less -F" is broken enough that I think git needs to potentially think about changing the defaults for the pager, or people should at least be aware of it. Older versions of less (at least up to less-487 - March 2017) do not have this bug. There were apparently 520, 527 and 529 releases in 2017 too, but I couldn't find their sources to verify if they were already broken - but 530 (February 2018) has the problem. The breakage is easy to see without git: (echo "hello"; sleep 5; echo "bye bye") | less -F which will result in no output at all for five seconds, and then you get both lines at once as "less" exits. It's not always obvious when using git, because when the terminal fills up, less also starts outputting, but the default options with -F are really horrible if you are looking for something uncommon, and "git log" doesn't respond at all. On the kernel tree, this is easy to see with something like git log --oneline --grep="The most important one is the mpt3sas fix" which takes a bit over 7 seconds before it shows the commit I was looking for. In contrast, if you do LESS=-RX git log --oneline --grep="The most important one is the mpt3sas fix" that (recent) commit is found and shown immediately. It still takes 7s for git to go through all history and decide "that was it", but at least you don't need to wait for the intermediate results. I've reported it as a bug in less, but I'm not sure what the reaction will be, the less releases seem to be very random. Linus
Re: [PATCHv4 1/6] Add missing includes and forward declarations
Elijah Newren wrote: [...] > Signed-off-by: Elijah Newren > --- [...] > 55 files changed, 132 insertions(+), 4 deletions(-) Reviewed-by: Jonathan Nieder Thanks.
Re: [PATCHv4 2/6] alloc: make allocate_alloc_state and clear_alloc_state more consistent
Elijah Newren wrote: > Since both functions are using the same data type, they should either both > refer to it as void *, or both use the real type (struct alloc_state *). > Opt for the latter. > > Reviewed-by: Jonathan Nieder > Signed-off-by: Elijah Newren Not worth rerolling for this, but these usually go in the opposite order to reflect the chronology: Signed-off-by: Elijah Newren Reviewed-by: Jonathan Nieder The patch still looks good to me. :)
Re: [PATCHv4 6/6] Remove forward declaration of an enum
Elijah Newren wrote: > According to http://c-faq.com/null/machexamp.html, sizeof(char*) != > sizeof(int*) on some platforms. Since an enum could be a char or int > (or long or...), knowing the size of the enum thus is important to > knowing the size of a pointer to an enum, so we cannot just forward > declare an enum the way we can a struct. (Also, modern C++ compilers > apparently define forward declarations of an enum to either be useless > because the enum was defined, or require an explicit size specifier, or > be a compilation error.) Beyond the effect on some obscure platforms, this also makes it possible to build with gcc -pedantic (which can be useful for finding some other problems). Thanks for fixing it. [...] > --- a/packfile.h > +++ b/packfile.h > @@ -1,12 +1,12 @@ > #ifndef PACKFILE_H > #define PACKFILE_H > > +#include "cache.h" > #include "oidset.h" > > /* in object-store.h */ > struct packed_git; > struct object_info; Not about this patch: comments like the above are likely to go stale, since nothing verifies they continue to be true. So we should remove them. #leftoverbits Reviewed-by: Jonathan Nieder
Re: [PATCHv4 0/6] Add missing includes and forward declares
Elijah Newren wrote: > 62 files changed, 152 insertions(+), 18 deletions(-) All 6 patches in this series are Reviewed-by: Jonathan Nieder Thanks for your patient work. Pointer to previous rounds for the curious: https://public-inbox.org/git/20180811043218.31456-1-new...@gmail.com/
"Changes not staged for commit" after cloning a repo on macOS
Hi everyone! I encountered a strange situation on OS X recently. I cloned a repository (https://github.com/kevinxucs/Sublime-Gitignore.git), went to folder, and saw "Changes not staged for commit" message for four specific files. It happened every time I repeated the procedure. I even was able to commit those to the repo. At first I thought there's something wrong with repo, but I cloned it on Ubuntu 16.04 and everything was OK; no "Changes not staged for commit" message. Does anyone have any idea? Thank you. Log: ``` $ git clone https://github.com/kevinxucs/Sublime-Gitignore.git Cloning into 'Sublime-Gitignore'... remote: Counting objects: 515, done. remote: Total 515 (delta 0), reused 0 (delta 0), pack-reused 515 Receiving objects: 100% (515/515), 102.14 KiB | 48.00 KiB/s, done. Resolving deltas: 100% (143/143), done. $ cd Sublime-Gitignore/ $ git status On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: boilerplates/Nanoc.gitignore modified: boilerplates/OpenCart.gitignore modified: boilerplates/SASS.gitignore modified: boilerplates/WordPress.gitignore no changes added to commit (use "git add" and/or "git commit -a") ``` The rest of the log is available at https://github.com/kevinxucs/Sublime-Gitignore/issues/6. (I don't want this email to become too long.) -- Hadi Safari http://hadisafari.ir/
[PATCH v2] worktree: add --quiet option
Add the '--quiet' option to git worktree, as for the other git commands. 'add' is the only command affected by it since all other commands, except 'list', are currently silent by default. Helped-by: Martin Ågren Helped-by: Duy Nguyen Helped-by: Eric Sunshine Signed-off-by: Elia Pinto --- This is the second version of the patch. Changes from the first version (https://public-inbox.org/git/CACsJy8A=zp7nfbuwyfep4uff3kssiaor3m0mtgvnhceyhsw...@mail.gmail.com/T/): - deleted garbage in git-worktree.c and deleted superfluous blank line in git-worktree.txt. - when giving "--quiet" to 'add', call git symbolic-ref also with "--quiet". - changed the commit message to be more general, but specifying why the "--quiet" option is meaningful only for the 'add' command of git-worktree. - in git-worktree.txt the option "--quiet" is described near the "--verbose" option. Documentation/git-worktree.txt | 4 builtin/worktree.c | 16 +--- t/t2025-worktree-add.sh| 5 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 9c26be40f..29a5b7e25 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -173,6 +173,10 @@ This can also be set up as the default behaviour by using the This format will remain stable across Git versions and regardless of user configuration. See below for details. +-q:: +--quiet:: + With 'add', suppress feedback messages. + -v:: --verbose:: With `prune`, report all removals. diff --git a/builtin/worktree.c b/builtin/worktree.c index a763dbdcc..41e771439 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -27,6 +27,7 @@ static const char * const worktree_usage[] = { struct add_opts { int force; int detach; + int quiet; int checkout; int keep_locked; }; @@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char *refname, if (!is_branch) argv_array_pushl(&cp.args, "update-ref", "HEAD", oid_to_hex(&commit->object.oid), NULL); - else + else { argv_array_pushl(&cp.args, "symbolic-ref", "HEAD", symref.buf, NULL); + if (opts->quiet) + argv_array_push(&cp.args, "--quiet"); + } + cp.env = child_env.argv; ret = run_command(&cp); if (ret) @@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char *refname, cp.argv = NULL; argv_array_clear(&cp.args); argv_array_pushl(&cp.args, "reset", "--hard", NULL); + if (opts->quiet) + argv_array_push(&cp.args, "--quiet"); cp.env = child_env.argv; ret = run_command(&cp); if (ret) @@ -437,6 +444,7 @@ static int add(int ac, const char **av, const char *prefix) OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")), OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")), OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")), + OPT__QUIET(&opts.quiet, N_("suppress progress reporting")), OPT_PASSTHRU(0, "track", &opt_track, NULL, N_("set up tracking mode (see git-branch(1))"), PARSE_OPT_NOARG | PARSE_OPT_OPTARG), @@ -491,8 +499,8 @@ static int add(int ac, const char **av, const char *prefix) } } } - - print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force); + if (!opts.quiet) + print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force); if (new_branch) { struct child_process cp = CHILD_PROCESS_INIT; @@ -500,6 +508,8 @@ static int add(int ac, const char **av, const char *prefix) argv_array_push(&cp.args, "branch"); if (new_branch_force) argv_array_push(&cp.args, "--force"); + if (opts.quiet) + argv_array_push(&cp.args, "--quiet"); argv_array_push(&cp.args, new_branch); argv_array_push(&cp.args, branch); if (opt_track) diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh index be6e09314..658647d83 100755 --- a/t/t2025-worktree-add.sh +++ b/t/t2025-worktree-add.sh @@ -252,6 +252,11 @@ test_expect_success 'add -B' ' test_cmp_rev master^ poodle ' +test_expect_success 'add --quiet' ' + git worktree add --quiet ../foo master >expected 2>&1 && + test_must_be_empty expected +' + test_expect_success 'local clone from linked checkout' ' git clone --local here here-clone && ( cd here-c
Re: [GSoC][PATCH v7 12/26] stash: refactor `show_stash()` to use the diff API
On 08/08, Paul-Sebastian Ungureanu wrote: > Currently, `show_stash()` uses `cmd_diff()` to generate > the output. After this commit, the output will be generated > using the internal API. > > Before this commit, `git stash show --quiet` would act like > `git diff` and error out if the stash is not empty. Now, the > `--quiet` option does not error out given an empty stash. I think this needs a bit more justification. As I mentioned in my comment to a previous patch, I'm not sure '--quiet' makes much sense with 'git stash show' (it will show nothing, and will always exit with an error code, as the stash will always contain something), but if we are supporting the same flags as 'git diff', and essentially just forwarding them, shouldn't they keep the same behaviour as well? > Signed-off-by: Paul-Sebastian Ungureanu > --- > builtin/stash--helper.c | 73 + > 1 file changed, 45 insertions(+), 28 deletions(-) > > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index 0c1efca6b..ec8c38c6f 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -10,6 +10,8 @@ > #include "run-command.h" > #include "dir.h" > #include "rerere.h" > +#include "revision.h" > +#include "log-tree.h" > > static const char * const git_stash_helper_usage[] = { > N_("git stash--helper list []"), > @@ -662,56 +664,71 @@ static int git_stash_config(const char *var, const char > *value, void *cb) > > static int show_stash(int argc, const char **argv, const char *prefix) > { > - int i, ret = 0; > - struct child_process cp = CHILD_PROCESS_INIT; > - struct argv_array args_refs = ARGV_ARRAY_INIT; > + int i; > + int flags = 0; > struct stash_info info; > + struct rev_info rev; > + struct argv_array stash_args = ARGV_ARRAY_INIT; > struct option options[] = { > OPT_END() > }; > > - argc = parse_options(argc, argv, prefix, options, > - git_stash_helper_show_usage, > - PARSE_OPT_KEEP_UNKNOWN); > + init_diff_ui_defaults(); > + git_config(git_diff_ui_config, NULL); > > - cp.git_cmd = 1; > - argv_array_push(&cp.args, "diff"); > + init_revisions(&rev, prefix); > > - /* Push arguments which are not options into args_refs. */ > - for (i = 0; i < argc; ++i) { > - if (argv[i][0] == '-') > - argv_array_push(&cp.args, argv[i]); > + /* Push arguments which are not options into stash_args. */ > + for (i = 1; i < argc; ++i) { > + if (argv[i][0] != '-') > + argv_array_push(&stash_args, argv[i]); > else > - argv_array_push(&args_refs, argv[i]); > - } > - > - if (get_stash_info(&info, args_refs.argc, args_refs.argv)) { > - child_process_clear(&cp); > - argv_array_clear(&args_refs); > - return -1; > + flags++; > } > > /* >* The config settings are applied only if there are not passed >* any flags. >*/ > - if (cp.args.argc == 1) { > + if (!flags) { > git_config(git_stash_config, NULL); > if (show_stat) > - argv_array_push(&cp.args, "--stat"); > + rev.diffopt.output_format |= DIFF_FORMAT_DIFFSTAT; > + if (show_patch) { > + rev.diffopt.output_format = ~DIFF_FORMAT_NO_OUTPUT; > + rev.diffopt.output_format |= DIFF_FORMAT_PATCH; > + } I failed to notice this in the previous patch (the problem existed there as well), but this changes the behaviour of 'git -c stash.showStat=false stash show '. Previously doing this would not show anything, which is the correct behaviour, while now still shows the diffstat. I think the show_stat variable is interpreted the wrong way around in the previous patch. Something else I noticed now that I was playing around more with the config options is that the parsing of the config options is not correctly done in the previous patch. It does a 'strcmp(var, "stash.showStat"))', but the config API makes all variables lowercase (config options are case insensitive, and making everything lowercase is the way to ensure that), so it should be 'strcmp(var, "stash.showstat"))', and similar for the 'stash.showpatch' config option. This all sounds like it would be nice to have some tests for these config options, to make sure we get it right, and won't break them in the future. > + } > > - if (show_patch) > - argv_array_push(&cp.args, "-p"); > + if (get_stash_info(&info, stash_args.argc, stash_args.argv)) { > + argv_array_clear(&stash_args); > + return -1; > } > > - argv_array_pushl(&cp.args, oid_to_hex(&info.b_commit), > - oid_to_hex(&info.w_commit), NULL); > + argc
Re: [PATCH v2] checkout: optimize "git checkout -b "
On 8/6/2018 10:25 AM, Ben Peart wrote: On 8/3/2018 11:58 AM, Duy Nguyen wrote: On Thu, Aug 02, 2018 at 02:02:00PM -0400, Ben Peart wrote: But if you still want to push it further, this is something I have in mind. It probably has bugs, but at least preliminary test shows me that it could skip 99% work inside unpack_trees() and not need to write the index. The main check to determine "checkout -b" is basically the new oidcmp() in merge_working_tree(). Not sure if I miss any condition in that check, I didn't look very closely at checkout code. Thanks Duy. I think this is an interesting idea to pursue but... when I tried running this patch on a virtualized repo it started triggering many object downloads. After taking a quick look, it appears that CE_UPDATE is set on every cache entry so check_updates() ends up calling checkout_entry() which writes out every file to the working tree - even those supposedly skipped by the skip-wortree bit. Oops. Not too surprising (you did say it probably has bugs :)) but it means I can't trivially get performance data on how much this will help. It also fails a lot of tests (see below). It experience does highlight the additional risk of this model of changing the underlying functions (vs the high level optimization of my original patch). In addition, the new special cases in those lower-level functions do add additional complexity and fragility to the codebase. So, like most things, to me it isn't a clear better/worse decision - it's just different. While I like the idea of general optimizations that could apply more broadly to other commands; I do worry about the additional complexity, amount of code churn, and associated risk with the change. When I have cycles, I'll take a look at how to fix this bug and get some performance data. I just wanted to give you a heads up that I'm not ignoring your patch, just that it is going to take additional time and effort before I can properly evaluate how much impact it will have. Now that the unpack-trees and cache-tree optimizations are settling down, I took a look at this proposed patch again with the intent of debugging why so many tests were broken by it. The most obvious first fix was for all the segment faults when dereferencing a NULL pointer. Adding an additional test so that we only perform the optimization when we actually have commit ID's to compare fixed a bunch of the test failures. The next fix was to resolve all the breaks caused by applying this optimization when sparse-checkout is turned on. Since we are skipping the logic to update the skip-worktree bit, I added an additional test so that we only perform the optimization when sparse checkout is not turned on. Of course, this does completely remove the optimization when using sparse checkout so it isn't a workable permanent solution but it let me make progress. There are still test failures with submodules and partial clone. I haven't found/added the necessary tests to prevent those breaks nor the few other remaining breaks. My current set of tests looks like this: if (!core_apply_sparse_checkout && old_branch_info->commit && new_branch_info->commit && !oidcmp(&old_branch_info->commit->object.oid, &new_branch_info->commit->object.oid)) { While I'm sure I could find and add additional tests to handle the remaining bugs, the net result is starting to look as fragile as the original patch. Unfortunately it has the additional downsides of 1) being at a much lower level where we risk breaking more code paths and 2) not being nearly as much savings (with the original patch checkout -b takes 0.3 seconds, this patch will make it take >4 seconds.) Net, net - I don't think this particular path is a better path to pursue. I understand the concern with the fragility of the current patch and it's set of tests to determine if the optimization is valid. I also understand the concern with the potential change in behavior (ie not showing the local changes - even though nothing has changed). Other than switching the optimization back to be "opt-in" via a config flag, I don't currently have a great answer. I'll keep thinking and looking but am open to suggestions! Test Summary Report --- ./t1011-read-tree-sparse-checkout.sh (Wstat: 256 Tests: 21 Failed: 1) Failed test: 20 Non-zero exit status: 1 ./t1400-update-ref.sh (Wstat: 256 Tests: 170 Failed: 73) Failed tests: 40, 42-45, 55-59, 70, 72, 82, 85, 87-88 90-100, 103-110, 113-119, 127, 129-130 132-133, 136-137, 140-147, 150-157, 160-166 170 Non-zero exit status: 1 ./t2011-checkout-invalid-head.sh (Wstat: 256 Tests: 10 Failed: 5) Failed tests: 3, 6-7, 9-10 Non-zero exit status: 1 ./t2015-checkout-unborn.s
Re: "Changes not staged for commit" after cloning a repo on macOS
On Wed, Aug 15, 2018 at 1:50 PM Hadi Safari wrote: > > Hi everyone! > > I encountered a strange situation on OS X recently. I cloned a > repository (https://github.com/kevinxucs/Sublime-Gitignore.git), went to > folder, and saw "Changes not staged for commit" message for four > specific files. It happened every time I repeated the procedure. I even > was able to commit those to the repo. > At first I thought there's something wrong with repo, but I cloned it on > Ubuntu 16.04 and everything was OK; no "Changes not staged for commit" > message. > > Does anyone have any idea? > > modified: boilerplates/Nanoc.gitignore > modified: boilerplates/OpenCart.gitignore > modified: boilerplates/SASS.gitignore > modified: boilerplates/WordPress.gitignore Taking a look at the repository's file list on GitHub[1], it shows that this is because HFS and APFS by default are case-insensitive. The file listing shows that there is a "nanoc.gitignore" and "Nanoc.gitignore". On APFS and HFS, those are the same file. As a result, one overwrites the other. This is discussed pretty regularly on the list[2], so you can find more details there. [1]: https://github.com/kevinxucs/Sublime-Gitignore/tree/master/boilerplates [2]: https://public-inbox.org/git/24a09b73-b4d4-4c22-bc1b-41b22cb59...@gmail.com/ is a fairly recent (fairly long) thread about this behavior. Hope this helps! Bryan
Re: [GSoC][PATCH v7 13/26] stash: update `git stash show` documentation
On 08/08, Paul-Sebastian Ungureanu wrote: > Add in documentation about the change of behavior regarding > the `--quiet` option, which was introduced in the last commit. > (the `--quiet` option does not exit anymore with erorr if it s/erorr/error/ > is given an empty stash as argument) If we want to keep the change in behaviour here (which I'm not sure about as mentioned in my comment on the previous patch), I think this should be folded into the previous patch. I don't think there's much value in having this as a separate commit, and folding it into the previous commit has the advantage that we can easily see that the new behaviour is documented. > Signed-off-by: Paul-Sebastian Ungureanu > --- > Documentation/git-stash.txt | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt > index e31ea7d30..d60ebdb96 100644 > --- a/Documentation/git-stash.txt > +++ b/Documentation/git-stash.txt > @@ -117,6 +117,9 @@ show [] []:: > You can use stash.showStat and/or stash.showPatch config variables > to change the default behavior. > > + It accepts any option known to `git diff`, but acts different on I notice that we are using single quotes for git commands in some places and backticks in other places in this man page. We may want to clean that up at some point. I wouldn't want to do it in this series though, as this is already long enough, and we've had this inconsistency for a while already. > + `--quiet` option and exit with zero regardless of differences. > + > pop [--index] [-q|--quiet] []:: > > Remove a single stashed state from the stash list and apply it > -- > 2.18.0.573.g56500d98f >
Re: Potential vulnerability: 'mixed up' output when commit has multiple signatures
Michał Górny wrote: > On Tue, 2018-08-14 at 22:35 -0700, Jonathan Nieder wrote: > > Michał Górny wrote: >>> I've been testing the git signature verification a bit and I've >>> discovered a troubling behavior when the commit object contains >>> multiple signatures. >> >> Thanks for discovering this. Do you mind if I take this conversation >> to the public mailing list? (I'd bounce the existing thread there if >> that's okay with you.) > > I've already asked somewhere else in the thread if you consider this > suitable for disclosure, and haven't received a reply yet. In any case, > I don't mind it. Thanks, doing so. Thanks again for the analysis and fix as well.
Re: Potential vulnerability: 'mixed up' output when commit has multiple signatures
On Tue, 2018-08-14 at 22:35 -0700, Jonathan Nieder wrote: > Hi, > > Michał Górny wrote: > > > I've been testing the git signature verification a bit and I've > > discovered a troubling behavior when the commit object contains > > multiple signatures. > > Thanks for discovering this. Do you mind if I take this conversation > to the public mailing list? (I'd bounce the existing thread there if > that's okay with you.) > I've already asked somewhere else in the thread if you consider this suitable for disclosure, and haven't received a reply yet. In any case, I don't mind it. I can resend my patch there if necessary too. -- Best regards, Michał Górny signature.asc Description: This is a digitally signed message part
Re: "less -F" is broken
On Wed, Aug 15, 2018 at 1:35 PM Linus Torvalds wrote: > > Sadly, as of less-530, the behavior of "less -F" is broken enough that > I think git needs to potentially think about changing the defaults for > the pager, or people should at least be aware of it. > > Older versions of less (at least up to less-487 - March 2017) do not > have this bug. There were apparently 520, 527 and 529 releases in > 2017 too, but I couldn't find their sources to verify if they were > already broken - but 530 (February 2018) has the problem. http://www.greenwoodsoftware.com/less/news.527.html http://www.greenwoodsoftware.com/less/news.520.html http://www.greenwoodsoftware.com/less/ Release notes for 520 and 527 contains: "Don't output terminal init sequence if using -F and file fits on one screen."
Re: [GSoC][PATCH v7 14/26] stash: convert store to builtin
On 08/08, Paul-Sebastian Ungureanu wrote: > Add stash store to the helper and delete the store_stash function > from the shell script. > > Add the usage string which was forgotten in the shell script. I think similarly to 'git stash create', which also doesn't appear in the usage, this was intentionally omitted in the shell script. The reason for the omission is that this is only intended to be useful in scripts, and not in interactive usage. As such it doesn't add much value in showing it in 'git stash -h'. Meanwhile it is in the synopsis in the man page. If we want to add it to the help output, I think it would be best to do so in a separate commit, and for 'git stash create' as well. But I'm not sure that's a good change. > Signed-off-by: Paul-Sebastian Ungureanu > --- > builtin/stash--helper.c | 52 + > git-stash.sh| 43 ++ > 2 files changed, 54 insertions(+), 41 deletions(-) > > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index ec8c38c6f..5ff810f8c 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -20,6 +20,7 @@ static const char * const git_stash_helper_usage[] = { > N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] > []"), > N_("git stash--helper branch []"), > N_("git stash--helper clear"), > + N_("git stash--helper store [-m|--message ] [-q|--quiet] > "), > NULL > }; > > @@ -58,6 +59,11 @@ static const char * const git_stash_helper_clear_usage[] = > { > NULL > }; > > +static const char * const git_stash_helper_store_usage[] = { > + N_("git stash--helper store [-m|--message ] [-q|--quiet] > "), > + NULL > +}; > + > static const char *ref_stash = "refs/stash"; > static int quiet; > static struct strbuf stash_index_path = STRBUF_INIT; > @@ -731,6 +737,50 @@ static int show_stash(int argc, const char **argv, const > char *prefix) > return 0; > } > > +static int do_store_stash(const char *w_commit, const char *stash_msg, > + int quiet) > +{ > + int ret = 0; > + struct object_id obj; > + > + if (!stash_msg) > + stash_msg = xstrdup("Created via \"git stash--helper > store\"."); I assume we're going to s/--helper// in a later commit? Not sure adding the '--helper' here is necessary, as a user would never invoke 'git stash--helper' directly, so they would expect the stash to be created by 'git stash store'. Anyway that's fairly minor, as I assume this is going to change by the end of the patch series. > + > + ret = get_oid(w_commit, &obj); > + if (!ret) { > + ret = update_ref(stash_msg, ref_stash, &obj, NULL, > + REF_FORCE_CREATE_REFLOG, > + quiet ? UPDATE_REFS_QUIET_ON_ERR : > + UPDATE_REFS_MSG_ON_ERR); > + } > + if (ret && !quiet) > + fprintf_ln(stderr, _("Cannot update %s with %s"), > +ref_stash, w_commit); > + > + return ret; > +} > + > +static int store_stash(int argc, const char **argv, const char *prefix) > +{ > + const char *stash_msg = NULL; > + struct option options[] = { > + OPT__QUIET(&quiet, N_("be quiet, only report errors")), > + OPT_STRING('m', "message", &stash_msg, "message", N_("stash > message")), > + OPT_END() > + }; > + > + argc = parse_options(argc, argv, prefix, options, > + git_stash_helper_store_usage, > + PARSE_OPT_KEEP_UNKNOWN); > + > + if (argc != 1) { > + fprintf(stderr, _("\"git stash--helper store\" requires one > argument\n")); > + return -1; > + } > + > + return do_store_stash(argv[0], stash_msg, quiet); > +} > + > int cmd_stash__helper(int argc, const char **argv, const char *prefix) > { > pid_t pid = getpid(); > @@ -765,6 +815,8 @@ int cmd_stash__helper(int argc, const char **argv, const > char *prefix) > return !!list_stash(argc, argv, prefix); > else if (!strcmp(argv[0], "show")) > return !!show_stash(argc, argv, prefix); > + else if (!strcmp(argv[0], "store")) > + return !!store_stash(argc, argv, prefix); > > usage_msg_opt(xstrfmt(_("unknown subcommand: %s"), argv[0]), > git_stash_helper_usage, options); > diff --git a/git-stash.sh b/git-stash.sh > index 0d05cbc1e..5739c5152 100755 > --- a/git-stash.sh > +++ b/git-stash.sh > @@ -191,45 +191,6 @@ create_stash () { > die "$(gettext "Cannot record working tree state")" > } > > -store_stash () { > - while test $# != 0 > - do > - case "$1" in > - -m|--message) > - shift > - stash_msg="$1" > - ;; > - -m*) > - stash_msg=${1#-m} > - ;
Re: "less -F" is broken
On Wed, Aug 15 2018, Linus Torvalds wrote: > Sadly, as of less-530, the behavior of "less -F" is broken enough that > I think git needs to potentially think about changing the defaults for > the pager, or people should at least be aware of it. Downloading & trying versions of it locally reveals that it's as of version 520, not 530. The last version before 520 is 487. Presumably it's covered by this item in the changelog: Don't output terminal init sequence if using -F and file fits on one screen[1] > Older versions of less (at least up to less-487 - March 2017) do not > have this bug. There were apparently 520, 527 and 529 releases in > 2017 too, but I couldn't find their sources to verify if they were > already broken - but 530 (February 2018) has the problem. FWIW they're not linked from http://www.greenwoodsoftware.com/less/download.html but you can just URL hack and see releases http://www.greenwoodsoftware.com/less/ and change links like http://www.greenwoodsoftware.com/less/less-530.tar.gz to http://www.greenwoodsoftware.com/less/less-520.tar.gz > The breakage is easy to see without git: > > (echo "hello"; sleep 5; echo "bye bye") | less -F > > which will result in no output at all for five seconds, and then you > get both lines at once as "less" exits. The relevant change in less is this, cutting out the non-relevant parts: diff --git a/less-487/forwback.c b/less-520/forwback.c index 83ae78e..680fa25 100644 --- a/less-487/forwback.c +++ b/less-520/forwback.c [...] @@ -444,3 +444,21 @@ get_back_scroll() return (sc_height - 2); return (1); /* infinity */ } + +/* + * Return number of displayable lines in the file. + * Stop counting at screen height + 1. + */ + public int +get_line_count() +{ + int nlines; + POSITION pos = ch_zero(); + + for (nlines = 0; nlines <= sc_height; nlines++) + { + pos = forw_line(pos); + if (pos == NULL_POSITION) break; + } + return nlines; +} [...] diff --git a/less-487/main.c b/less-520/main.c index 960d120..6d54851 100644 --- a/less-487/main.c +++ b/less-520/main.c [...] @@ -273,10 +275,19 @@ main(argc, argv) { if (edit_stdin()) /* Edit standard input */ quit(QUIT_ERROR); + if (quit_if_one_screen) + line_count = get_line_count(); } else { if (edit_first()) /* Edit first valid file in cmd line */ quit(QUIT_ERROR); + if (quit_if_one_screen) + { + if (nifile() == 1) + line_count = get_line_count(); + else /* If more than one file, -F can not be used */ + quit_if_one_screen = FALSE; + } } init(); diff --git a/less-487/screen.c b/less-520/screen.c index ad3fca1..2d51bbc 100644 --- a/less-487/screen.c +++ b/less-520/screen.c [...] @@ -1538,7 +1555,9 @@ win32_deinit_term() init() { #if !MSDOS_COMPILER - if (!no_init) + if (quit_if_one_screen && line_count >= sc_height) + quit_if_one_screen = FALSE; + if (!no_init && !quit_if_one_screen) tputs(sc_init, sc_height, putchr); if (!no_keypad) tputs(sc_s_keypad, sc_height, putchr); If you undo that first changed part in main.c your test case prints "hello" to the terminal immediately. > It's not always obvious when using git, because when the terminal > fills up, less also starts outputting, but the default options with -F > are really horrible if you are looking for something uncommon, and > "git log" doesn't respond at all. > > On the kernel tree, this is easy to see with something like > >git log --oneline --grep="The most important one is the mpt3sas fix" > > which takes a bit over 7 seconds before it shows the commit I was looking for. > > In contrast, if you do > >LESS=-RX git log --oneline --grep="The most important one is the mpt3sas > fix" > > that (recent) commit is found and shown immediately. It still takes 7s > for git to go through all history and decide "that was it", but at > least you don't need to wait for the intermediate results. > > I've reported it as a bug in less, but I'm not sure what the reaction > will be, the less releases seem to be very random. Via bug-l...@gnu.org? Is this report available online somewhere? Anyway, CC-ing that address since my digging into this will be useful to them. 1. http://www.greenwoodsoftware.com/less/news.520.html
Re: [PATCH] gpg-interface.c: detect and reject multiple signatures on commits
Michał Górny wrote: > GnuPG supports creating signatures consisting of multiple signature > packets. If such a signature is verified, it outputs all the status > messages for each signature separately. However, git currently does not > account for such scenario and gets terribly confused over getting > multiple *SIG statuses. > > For example, if a malicious party alters a signed commit and appends > a new untrusted signature, git is going to ignore the original bad > signature and report untrusted commit instead. However, %GK and %GS > format strings may still expand to the data corresponding > to the original signature, potentially tricking the scripts into > trusting the malicious commit. > > Given that the use of multiple signatures is quite rare, git does not > support creating them without jumping through a few hoops, and finally > supporting them properly would require extensive API improvement, it > seems reasonable to just reject them at the moment. > --- Thanks for the clear analysis and fix. May we have your sign-off? See https://www.kernel.org/pub/software/scm/git/docs/SubmittingPatches.html#sign-off (or the equivalent section of your local copy of Documentation/SubmittingPatches) for what this means. > gpg-interface.c | 38 ++ > 1 file changed, 30 insertions(+), 8 deletions(-) > > diff --git a/gpg-interface.c b/gpg-interface.c > index 09ddfbc26..4e03aec15 100644 > --- a/gpg-interface.c > +++ b/gpg-interface.c > @@ -24,21 +24,23 @@ void signature_check_clear(struct signature_check *sigc) > static struct { > char result; > const char *check; > + int is_status; > } sigcheck_gpg_status[] = { > - { 'G', "\n[GNUPG:] GOODSIG " }, > - { 'B', "\n[GNUPG:] BADSIG " }, > - { 'U', "\n[GNUPG:] TRUST_NEVER" }, > - { 'U', "\n[GNUPG:] TRUST_UNDEFINED" }, > - { 'E', "\n[GNUPG:] ERRSIG "}, > - { 'X', "\n[GNUPG:] EXPSIG "}, > - { 'Y', "\n[GNUPG:] EXPKEYSIG "}, > - { 'R', "\n[GNUPG:] REVKEYSIG "}, > + { 'G', "\n[GNUPG:] GOODSIG ", 1 }, > + { 'B', "\n[GNUPG:] BADSIG ", 1 }, > + { 'U', "\n[GNUPG:] TRUST_NEVER", 0 }, > + { 'U', "\n[GNUPG:] TRUST_UNDEFINED", 0 }, > + { 'E', "\n[GNUPG:] ERRSIG ", 1}, > + { 'X', "\n[GNUPG:] EXPSIG ", 1}, > + { 'Y', "\n[GNUPG:] EXPKEYSIG ", 1}, > + { 'R', "\n[GNUPG:] REVKEYSIG ", 1}, > }; nit: I wonder if making is_status into a flag field (like 'option' in git.c's cmd_struct) and having an explicit SIGNATURE_STATUS value to put there would make this easier to read. It's not clear to me that the name is_status or SIGNATURE_STATUS captures what this field represents. Aren't these all sigcheck statuses? Can you describe briefly what distinguishes the cases where this should be 0 versus 1? > > static void parse_gpg_output(struct signature_check *sigc) > { > const char *buf = sigc->gpg_status; > int i; > + int had_status = 0; > > /* Iterate over all search strings */ > for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) { > @@ -50,6 +52,10 @@ static void parse_gpg_output(struct signature_check *sigc) > continue; > found += strlen(sigcheck_gpg_status[i].check); > } > + > + if (sigcheck_gpg_status[i].is_status) > + had_status++; > + > sigc->result = sigcheck_gpg_status[i].result; > /* The trust messages are not followed by key/signer > information */ > if (sigc->result != 'U') { > @@ -62,6 +68,22 @@ static void parse_gpg_output(struct signature_check *sigc) > } > } > } > + > + /* > + * GOODSIG, BADSIG etc. can occur only once for each signature. > + * Therefore, if we had more than one then we're dealing with multiple > + * signatures. We don't support them currently, and they're rather > + * hard to create, so something is likely fishy and we should reject > + * them altogether. > + */ > + if (had_status > 1) { > + sigc->result = 'E'; > + /* Clear partial data to avoid confusion */ > + if (sigc->signer) > + FREE_AND_NULL(sigc->signer); > + if (sigc->key) > + FREE_AND_NULL(sigc->key); > + } Makes sense to me. > } > > int check_signature(const char *payload, size_t plen, const char *signature, > -- > 2.18.0 Can we have a test to make sure this behavior doesn't regress? See t/README for an overview of the test framework and "git grep -e gpg t/" for some examples. The result looks good. Thanks again for writing it. Sincerely, Jonathan
Re: "less -F" is broken
On Wed, Aug 15, 2018 at 2:29 PM Ævar Arnfjörð Bjarmason wrote: > > FWIW they're not linked from > http://www.greenwoodsoftware.com/less/download.html but you can just URL > hack and see releases http://www.greenwoodsoftware.com/less/ and change > links like http://www.greenwoodsoftware.com/less/less-530.tar.gz to > http://www.greenwoodsoftware.com/less/less-520.tar.gz I should have just tried that. I just downloaded the ones linked to, made a git archive of the history, and started bisecting. Which was all pointless extra work, since it was in the last release, but whatever. > > I've reported it as a bug in less, but I'm not sure what the reaction > > will be, the less releases seem to be very random. > > Via bug-l...@gnu.org? Heh. Another thing I didn't actually find. No, I just emailed Mark Nudelman directly, because that's what the FAQ says to do: "There is a list of known bugs here. If you find a bug that is not in the list, please send email to the author. Describe the bug in as much detail as possible, and I'll do what I can to help resolve the problem." and it doesn't mention any mailing list. > Is this report available online somewhere? It was not all that different from the email to the git list - just giving the trivial test-case and my (limited) bisection result. The data you dug up is much more useful. Linus
Re: "less -F" is broken
On Wed, Aug 15, 2018 at 2:29 PM Ævar Arnfjörð Bjarmason wrote: > > Downloading & trying versions of it locally reveals that it's as of > version 520, not 530. The last version before 520 is 487. Presumably > it's covered by this item in the changelog: > > Don't output terminal init sequence if using -F and file fits on one > screen[1] Side note: that's sad, because we already use X in the default exactly for that reason. So apparently "less" was broken for us to fix something that we already had long solved. The code basically tried to do "automatic X when F is set". And all that line_count stuff (which is what breaks) is pointless when -X is already given. That does give a possible fix: just stop doing the line_count thing if no_init is set. So "-F" would continue to be broken, but "-FX" would work. Something like the attached patch, perhaps? Linus main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 179bd78..961a9db 100644 --- a/main.c +++ b/main.c @@ -59,6 +59,7 @@ extern int missing_cap; extern int know_dumb; extern int pr_type; extern int quit_if_one_screen; +extern int no_init; /* @@ -274,7 +275,7 @@ main(argc, argv) { if (edit_stdin()) /* Edit standard input */ quit(QUIT_ERROR); - if (quit_if_one_screen) + if (quit_if_one_screen && !no_init) line_count = get_line_count(); } else {
Re: [GSoC][PATCH v7 15/26] stash: convert create to builtin
On 08/08, Paul-Sebastian Ungureanu wrote: > Add stash create to the helper. > > Signed-off-by: Paul-Sebastian Ungureanu > --- > builtin/stash--helper.c | 406 > git-stash.sh| 2 +- > 2 files changed, 407 insertions(+), 1 deletion(-) > > diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c > index 5ff810f8c..a4e57899b 100644 > --- a/builtin/stash--helper.c > +++ b/builtin/stash--helper.c > @@ -21,6 +21,7 @@ static const char * const git_stash_helper_usage[] = { > N_("git stash--helper branch []"), > N_("git stash--helper clear"), > N_("git stash--helper store [-m|--message ] [-q|--quiet] > "), > + N_("git stash--helper create []"), > NULL > }; > > @@ -64,6 +65,11 @@ static const char * const git_stash_helper_store_usage[] = > { > NULL > }; > > +static const char * const git_stash_helper_create_usage[] = { > + N_("git stash--helper create []"), > + NULL > +}; > + > static const char *ref_stash = "refs/stash"; > static int quiet; > static struct strbuf stash_index_path = STRBUF_INIT; > @@ -781,6 +787,404 @@ static int store_stash(int argc, const char **argv, > const char *prefix) > return do_store_stash(argv[0], stash_msg, quiet); > } > > [...] > > + > +static int do_create_stash(int argc, const char **argv, const char *prefix, > +const char **stash_msg, int include_untracked, > +int patch_mode, struct stash_info *info) > +{ > + int untracked_commit_option = 0; > + int ret = 0; > + int subject_len; > + int flags; > + const char *head_short_sha1 = NULL; > + const char *branch_ref = NULL; > + const char *head_subject = NULL; > + const char *branch_name = "(no branch)"; > + struct commit *head_commit = NULL; > + struct commit_list *parents = NULL; > + struct strbuf msg = STRBUF_INIT; > + struct strbuf commit_tree_label = STRBUF_INIT; > + struct strbuf out = STRBUF_INIT; > + struct strbuf final_stash_msg = STRBUF_INIT; > + > + read_cache_preload(NULL); > + refresh_cache(REFRESH_QUIET); > + > + if (!check_changes(argv, include_untracked, prefix)) { > + ret = 1; > + goto done; I wonder if we can just 'exit(0)' here, instead of returning. This whole command is a builtin, and I *think* outside of 'libgit.a' exiting early is fine. It does mean that we're not free'ing the memory though, which means a leak checker would probably complain. So dunno. It would simplify the code a little, but not sure it's worth it. > + } > + > + if (get_oid("HEAD", &info->b_commit)) { > + fprintf_ln(stderr, "You do not have the initial commit yet"); > + ret = -1; > + goto done; > + } else { > + head_commit = lookup_commit(the_repository, &info->b_commit); > + } > + > + branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags); > + if (flags & REF_ISSYMREF) > + branch_name = strrchr(branch_ref, '/') + 1; > + head_short_sha1 = find_unique_abbrev(&head_commit->object.oid, > + DEFAULT_ABBREV); > + subject_len = find_commit_subject(get_commit_buffer(head_commit, NULL), > + &head_subject); > + strbuf_addf(&msg, "%s: %s %.*s\n", branch_name, head_short_sha1, > + subject_len, head_subject); I think this can be written in a slightly simpler way: head_short_sha1 = find_unique_abbrev(&head_commit->object.oid, DEFAULT_ABBREV); strbuf_addf(&msg, "%s: %s", branch_name, head_short_sha1); pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg); strbuf_addch(&msg, '\n'); The other advantage this brings is that it is consistent with other places where we print/use the subject of a commit (e.g. in 'git reset --hard'). > + > + strbuf_addf(&commit_tree_label, "index on %s\n", msg.buf); > + commit_list_insert(head_commit, &parents); > + if (write_cache_as_tree(&info->i_tree, 0, NULL) || > + commit_tree(commit_tree_label.buf, commit_tree_label.len, > + &info->i_tree, parents, &info->i_commit, NULL, NULL)) { > + fprintf_ln(stderr, "Cannot save the current index state"); Looks like this message is translated in the current 'git stash' implementation, so it should be here as well. Same for the messages below. > + ret = -1; > + goto done; > + } > + > + if (include_untracked && get_untracked_files(argv, 1, > + include_untracked, &out)) { > + if (save_untracked_files(info, &msg, &out)) { > + printf_ln("Cannot save the untracked files"); Why does this go to stdout, whereas "Cannot save the current index state" above goes to stderr? In the shell version of git stash th
Re: [GSoC][PATCH v7 00/26] Convert "git stash" to C builtin
On 08/08, Paul-Sebastian Ungureanu wrote: > Hello, > > Here is the whole `git stash` C version. Some of the previous > patches were already reviewed (up to and including "stash: convert > store to builtin"), but there are some which were not > (starting with "stash: convert create to builtin"). Thanks for this new iteration, and sorry I took a while to find some time to review this. I had another read through the patches up until patch 15, and left some comments, before running out of time again. I hope to find some time in the next few days to go through the rest of the series as well. One more comment in terms of the structure of the series. The patches doing the actual conversion from shell to C seem to be interleaved with cleanup patches and patches that make the C version use more internal APIs. I'd suggest putting all the cleanup patches (e.g. "stash: change `git stash show` usage text and documentation") to the front of the series, as that's more likely to be uncontroversial, and could maybe even be merged by itself. Then I'd put all the conversion from shell to C patches, and only once everything is converted I'd put the patches to use more of the internal APIs rather than using run_command everywhere. A possible alternative would be to squash the patches to replace the run_command calls with patches that use the internal API directly, to save the reviewers some time by reading through less churn. Though I'm kind of on the fence with that, as a faithful conversion using 'run_command' may be easier to review as a first step. Hope this helps! > In order to see the difference between the shell version and > the C version, I ran `time` on: > > * git test suite (t3903-stash.sh, t3904-stash-patch.sh, > t3905-stash-include-untracked.sh and t3906-stash-submodule.sh) > > t3903-stash.sh: > ** SHELL: 12,69s user 9,95s system 109% cpu 20,730 total > ** C: 2,67s user 2,84s system 105% cpu 5,206 total > > t3904-stash-patch.sh: > ** SHELL: 1,43s user 0,94s system 106% cpu 2,242 total > ** C: 1,01s user 0,58s system 104% cpu 1,530 total > > t3905-stash-include-untracked.sh > ** SHELL: 2,22s user 1,73s system 110% cpu 3,569 total > ** C: 0,59s user 0,57s system 106% cpu 1,085 total > > t3906-stash-submodule.sh > ** SHELL: 2,89s user 2,99s system 106% cpu 5,527 total > ** C: 2,21s user 2,61s system 105% cpu 4,568 total > > TOTAL: > ** SHELL: 19.23s user 15.61s system > ** C: 6.48s user 6.60s system Awesome! > * a git repository with 4000 files: 1000 not changed, > 1000 staged files, 1000 unstaged files, 1000 untracked. > In this case I ran some of the most used commands: > > git stash push: > > ** SHELL: 0,12s user 0,21s system 101% cpu 0,329 total > ** C: 0,06s user 0,13s system 105% cpu 0,185 total > > git stash push -u: > > ** SHELL: 0,18s user 0,27s system 108% cpu 0,401 total > ** C: 0,09s user 0,19s system 103% cpu 0,267 total > > git stash pop: > > ** SHELL: 0,16s user 0,26s system 103% cpu 0,399 total > ** C: 0,13s user 0,19s system 102% cpu 0,308 total > > Best regards, > Paul Ungureanu > > > Joel Teichroeb (5): > stash: improve option parsing test coverage > stash: convert apply to builtin > stash: convert drop and clear to builtin > stash: convert branch to builtin > stash: convert pop to builtin > > Paul-Sebastian Ungureanu (21): > sha1-name.c: added 'get_oidf', which acts like 'get_oid' > stash: update test cases conform to coding guidelines > stash: renamed test cases to be more descriptive > stash: implement the "list" command in the builtin > stash: convert show to builtin > stash: change `git stash show` usage text and documentation > stash: refactor `show_stash()` to use the diff API > stash: update `git stash show` documentation > stash: convert store to builtin > stash: convert create to builtin > stash: replace spawning a "read-tree" process > stash: avoid spawning a "diff-index" process > stash: convert push to builtin > stash: make push to be quiet > stash: add tests for `git stash push -q` > stash: replace spawning `git ls-files` child process > stash: convert save to builtin > stash: convert `stash--helper.c` into `stash.c` > stash: optimize `get_untracked_files()` and `check_changes()` > stash: replace all `write-tree` child processes with API calls > stash: replace all "git apply" child processes with API calls > > Documentation/git-stash.txt |7 +- > Makefile|2 +- > builtin.h |1 + > builtin/stash.c | 1562 +++ > cache.h |1 + > git-stash.sh| 752 - > git.c |1 + > sha1-name.c | 19 + > t
Re: [PATCH v2] worktree: add --quiet option
On 08/15, Elia Pinto wrote: > Add the '--quiet' option to git worktree, > as for the other git commands. 'add' is the > only command affected by it since all other > commands, except 'list', are currently > silent by default. > > Helped-by: Martin Ågren > Helped-by: Duy Nguyen > Helped-by: Eric Sunshine > Signed-off-by: Elia Pinto > --- > This is the second version of the patch. > > Changes from the first version > (https://public-inbox.org/git/CACsJy8A=zp7nfbuwyfep4uff3kssiaor3m0mtgvnhceyhsw...@mail.gmail.com/T/): > > - deleted garbage in git-worktree.c and deleted > superfluous blank line in git-worktree.txt. > - when giving "--quiet" to 'add', call git symbolic-ref also with > "--quiet". > - changed the commit message to be more general, but > specifying why the "--quiet" option is meaningful only for > the 'add' command of git-worktree. > - in git-worktree.txt the option > "--quiet" is described near the "--verbose" option. > > Documentation/git-worktree.txt | 4 > builtin/worktree.c | 16 +--- > t/t2025-worktree-add.sh| 5 + > 3 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt > index 9c26be40f..29a5b7e25 100644 > --- a/Documentation/git-worktree.txt > +++ b/Documentation/git-worktree.txt > @@ -173,6 +173,10 @@ This can also be set up as the default behaviour by > using the > This format will remain stable across Git versions and regardless of > user > configuration. See below for details. > > +-q:: > +--quiet:: > + With 'add', suppress feedback messages. Very minor nit here, we seem to use backticks everywhere else in this document, maybe we sould do that here as well? Not sure it's worth another iteration though. The rest of the patch looks good to me, thanks! > -v:: > --verbose:: > With `prune`, report all removals. > diff --git a/builtin/worktree.c b/builtin/worktree.c > index a763dbdcc..41e771439 100644 > --- a/builtin/worktree.c > +++ b/builtin/worktree.c > @@ -27,6 +27,7 @@ static const char * const worktree_usage[] = { > struct add_opts { > int force; > int detach; > + int quiet; > int checkout; > int keep_locked; > }; > @@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char > *refname, > if (!is_branch) > argv_array_pushl(&cp.args, "update-ref", "HEAD", >oid_to_hex(&commit->object.oid), NULL); > - else > + else { > argv_array_pushl(&cp.args, "symbolic-ref", "HEAD", >symref.buf, NULL); > + if (opts->quiet) > + argv_array_push(&cp.args, "--quiet"); > + } > + > cp.env = child_env.argv; > ret = run_command(&cp); > if (ret) > @@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char > *refname, > cp.argv = NULL; > argv_array_clear(&cp.args); > argv_array_pushl(&cp.args, "reset", "--hard", NULL); > + if (opts->quiet) > + argv_array_push(&cp.args, "--quiet"); > cp.env = child_env.argv; > ret = run_command(&cp); > if (ret) > @@ -437,6 +444,7 @@ static int add(int ac, const char **av, const char > *prefix) > OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named > commit")), > OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new > working tree")), > OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working > tree locked")), > + OPT__QUIET(&opts.quiet, N_("suppress progress reporting")), > OPT_PASSTHRU(0, "track", &opt_track, NULL, >N_("set up tracking mode (see git-branch(1))"), >PARSE_OPT_NOARG | PARSE_OPT_OPTARG), > @@ -491,8 +499,8 @@ static int add(int ac, const char **av, const char > *prefix) > } > } > } > - > - print_preparing_worktree_line(opts.detach, branch, new_branch, > !!new_branch_force); > + if (!opts.quiet) > + print_preparing_worktree_line(opts.detach, branch, new_branch, > !!new_branch_force); > > if (new_branch) { > struct child_process cp = CHILD_PROCESS_INIT; > @@ -500,6 +508,8 @@ static int add(int ac, const char **av, const char > *prefix) > argv_array_push(&cp.args, "branch"); > if (new_branch_force) > argv_array_push(&cp.args, "--force"); > + if (opts.quiet) > + argv_array_push(&cp.args, "--quiet"); > argv_array_push(&cp.args, new_branch); > argv_array_push(&cp.args, branch); > if (opt_track) > diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh > index be6e09314..658647d83 100755 > --- a/t/t2025-worktree-add.sh >