* [PATCH v6 3/7] completion: bisect: complete custom terms and related options
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
git bisect supports the use of custom terms via the --term-(new|bad) and
--term-(old|good) options, but the completion code doesn't know about
these options or the new subcommands they define.
Add support for these options and the custom subcommands by checking for
BISECT_TERMS and adding them to the list of subcommands. Add tests.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 32 ++++++++++++++++++++++++--
t/t9902-completion.sh | 15 ++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 06d0b156e7..6a3d9c7760 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1449,7 +1449,20 @@ _git_bisect ()
{
__git_has_doubledash && return
- local subcommands="start bad new good old skip reset visualize replay log run help"
+ __git_find_repo_path
+
+ # If a bisection is in progress get the terms being used.
+ local term_bad term_good
+ if [ -f "$__git_repo_path"/BISECT_TERMS ]; then
+ term_bad=$(__git bisect terms --term-bad)
+ term_good=$(__git bisect terms --term-good)
+ fi
+
+ # We will complete any custom terms, but still always complete the
+ # more usual bad/new/good/old because git bisect gives a good error
+ # message if these are given when not in use, and that's better than
+ # silent refusal to complete if the user is confused.
+ local subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__git_find_repo_path
@@ -1462,7 +1475,22 @@ _git_bisect ()
fi
case "$subcommand" in
- bad|new|good|old|reset|skip|start)
+ start)
+ case "$cur" in
+ --*)
+ __gitcomp "--term-new --term-bad --term-old --term-good"
+ return
+ ;;
+ *)
+ __git_complete_refs
+ ;;
+ esac
+ ;;
+ terms)
+ __gitcomp "--term-good --term-old --term-bad --term-new"
+ return
+ ;;
+ bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
__git_complete_refs
;;
*)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 7388c892cf..304903b1a7 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1321,9 +1321,12 @@ test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
test_completion "git bisect " <<-\EOF
start Z
bad Z
+ custom_new Z
+ custom_old Z
new Z
good Z
old Z
+ terms Z
skip Z
reset Z
visualize Z
@@ -1335,6 +1338,18 @@ test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
)
'
+test_expect_success 'git-bisect - options to terms subcommand are candidates' '
+ (
+ cd git-bisect &&
+ test_completion "git bisect terms --" <<-\EOF
+ --term-bad Z
+ --term-good Z
+ --term-new Z
+ --term-old Z
+ EOF
+ )
+'
+
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
HEAD Z
--
2.43.0
^ permalink raw reply related
* [PATCH v6 2/7] completion: bisect: complete bad, new, old, and help subcommands
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
The bad, new, old and help subcommands to git-bisect(1) are not
completed.
Add the bad, new, old, and help subcommands to the appropriate lists
such that the commands and their possible ref arguments are completed.
Add tests.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 4 +-
t/t9902-completion.sh | 71 ++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 185b47d802..06d0b156e7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1449,7 +1449,7 @@ _git_bisect ()
{
__git_has_doubledash && return
- local subcommands="start bad good skip reset visualize replay log run"
+ local subcommands="start bad new good old skip reset visualize replay log run help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__git_find_repo_path
@@ -1462,7 +1462,7 @@ _git_bisect ()
fi
case "$subcommand" in
- bad|good|reset|skip|start)
+ bad|new|good|old|reset|skip|start)
__git_complete_refs
;;
*)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index a5d4e900a2..7388c892cf 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1264,6 +1264,77 @@ test_expect_success 'git switch - with no options, complete local branches and u
EOF
'
+test_expect_success 'git bisect - when not bisecting, complete only replay and start subcommands' '
+ test_completion "git bisect " <<-\EOF
+ replay Z
+ start Z
+ EOF
+'
+
+test_expect_success 'setup for git-bisect tests requiring a repo' '
+ git init git-bisect &&
+ (
+ cd git-bisect &&
+ echo "initial contents" >file &&
+ git add file &&
+ git commit -am "Initial commit" &&
+ git tag initial &&
+ echo "new line" >>file &&
+ git commit -am "First change" &&
+ echo "another new line" >>file &&
+ git commit -am "Second change" &&
+ git tag final
+ )
+'
+
+test_expect_success 'git bisect - start subcommand arguments before double-dash are completed as revs' '
+ (
+ cd git-bisect &&
+ test_completion "git bisect start " <<-\EOF
+ HEAD Z
+ final Z
+ initial Z
+ master Z
+ EOF
+ )
+'
+
+# Note that these arguments are <pathspec>s, which in practice the fallback
+# completion (not the git completion) later ends up completing as paths.
+test_expect_success 'git bisect - start subcommand arguments after double-dash are not completed' '
+ (
+ cd git-bisect &&
+ test_completion "git bisect start final initial -- " ""
+ )
+'
+
+test_expect_success 'setup for git-bisect tests requiring ongoing bisection' '
+ (
+ cd git-bisect &&
+ git bisect start --term-new=custom_new --term-old=custom_old final initial
+ )
+'
+
+test_expect_success 'git-bisect - when bisecting all subcommands are candidates' '
+ (
+ cd git-bisect &&
+ test_completion "git bisect " <<-\EOF
+ start Z
+ bad Z
+ new Z
+ good Z
+ old Z
+ skip Z
+ reset Z
+ visualize Z
+ replay Z
+ log Z
+ run Z
+ help Z
+ EOF
+ )
+'
+
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
HEAD Z
--
2.43.0
^ permalink raw reply related
* [PATCH v6 4/7] completion: bisect: complete missing --first-parent and --no-checkout options
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
The --first-parent and --no-checkout options to the start subcommand of
git-bisect(1) are not completed.
Enable completion of the --first-parent and --no-checkout options to the
start subcommand. Add test.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 2 +-
t/t9902-completion.sh | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6a3d9c7760..57c6e09968 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1478,7 +1478,7 @@ _git_bisect ()
start)
case "$cur" in
--*)
- __gitcomp "--term-new --term-bad --term-old --term-good"
+ __gitcomp "--first-parent --no-checkout --term-new --term-bad --term-old --term-good"
return
;;
*)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 304903b1a7..8fcd1cfa7e 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1271,6 +1271,17 @@ test_expect_success 'git bisect - when not bisecting, complete only replay and s
EOF
'
+test_expect_success 'git bisect - complete options to start subcommand' '
+ test_completion "git bisect start --" <<-\EOF
+ --term-new Z
+ --term-bad Z
+ --term-old Z
+ --term-good Z
+ --no-checkout Z
+ --first-parent Z
+ EOF
+'
+
test_expect_success 'setup for git-bisect tests requiring a repo' '
git init git-bisect &&
(
--
2.43.0
^ permalink raw reply related
* [PATCH v6 1/7] completion: tests: always use 'master' for default initial branch name
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
The default initial branch name can normally be configured using the
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME environment variable. However,
when testing e.g. <rev> completion it's convenient to know the
exact initial branch name that will be used.
To achieve that without too much trouble it is considered sufficient
to force the default initial branch name to 'master' for all of
t9902-completion.sh.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
t/t9902-completion.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index aa9a614de3..a5d4e900a2 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -5,6 +5,11 @@
test_description='test bash completion'
+# Override environment and always use master for the default initial branch
+# name for these tests, so that rev completion candidates are as expected.
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./lib-bash.sh
complete ()
--
2.43.0
^ permalink raw reply related
* [PATCH v6 5/7] completion: new function __git_complete_log_opts
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
The options accepted by git-log are also accepted by at least one other
command (git-bisect). Factor the common option completion code into a
new function and use it from _git_log. The new function leaves
COMPREPLY empty if no option candidates are found, so that callers can
safely check it to determine if completion for other arguments should be
attempted.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 57c6e09968..b9ebd5e409 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2089,10 +2089,12 @@ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-c
__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
-_git_log ()
+# Complete porcelain (i.e. not git-rev-list) options and at least some
+# option arguments accepted by git-log. Note that this same set of options
+# are also accepted by some other git commands besides git-log.
+__git_complete_log_opts ()
{
- __git_has_doubledash && return
- __git_find_repo_path
+ COMPREPLY=()
local merge=""
if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
@@ -2186,6 +2188,16 @@ _git_log ()
return
;;
esac
+}
+
+_git_log ()
+{
+ __git_has_doubledash && return
+ __git_find_repo_path
+
+ __git_complete_log_opts
+ [ ${#COMPREPLY[@]} -eq 0 ] || return
+
__git_complete_revlist
}
--
2.43.0
^ permalink raw reply related
* [PATCH v6 7/7] completion: bisect: recognize but do not complete view subcommand
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
The "view" alias for the visualize subcommand is neither completed nor
recognized. It's undesirable to complete it because it's first letters
are the same as for visualize, making completion less rather than more
efficient without adding much in the way of interface discovery.
However, it needs to be recognized in order to enable log option
completion for it.
Recognize but do not complete the view command by creating and using
separate lists of completable_subcommands and all_subcommands. Add
tests.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 15 +++++++++++----
t/t9902-completion.sh | 24 ++++++++++++++++++++++++
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5337ae4ce2..0734debc11 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1462,12 +1462,19 @@ _git_bisect ()
# more usual bad/new/good/old because git bisect gives a good error
# message if these are given when not in use, and that's better than
# silent refusal to complete if the user is confused.
- local subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
- local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ #
+ # We want to recognize 'view' but not complete it, because it overlaps
+ # with 'visualize' too much and is just an alias for it.
+ #
+ local completable_subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
+ local all_subcommands="$completable_subcommands view"
+
+ local subcommand="$(__git_find_on_cmdline "$all_subcommands")"
+
if [ -z "$subcommand" ]; then
__git_find_repo_path
if [ -f "$__git_repo_path"/BISECT_START ]; then
- __gitcomp "$subcommands"
+ __gitcomp "$completable_subcommands"
else
__gitcomp "replay start"
fi
@@ -1490,7 +1497,7 @@ _git_bisect ()
__gitcomp "--term-good --term-old --term-bad --term-new"
return
;;
- visualize)
+ visualize|view)
__git_complete_log_opts
return
;;
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index b989388e7e..70557eb684 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1376,6 +1376,30 @@ test_expect_success 'git-bisect - git-log options to visualize subcommand are ca
)
'
+test_expect_success 'git-bisect - view subcommand is not a candidate' '
+ (
+ cd git-bisect &&
+ test_completion "git bisect vi" <<-\EOF
+ visualize Z
+ EOF
+ )
+'
+
+test_expect_success 'git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
+ (
+ cd git-bisect &&
+ # The completion used for git-log and here does not complete
+ # every git-log option, so rather than hope to stay in sync
+ # with exactly what it does we will just spot-test here.
+ test_completion "git bisect view --sta" <<-\EOF &&
+ --stat Z
+ EOF
+ test_completion "git bisect view --summar" <<-\EOF
+ --summary Z
+ EOF
+ )
+'
+
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
HEAD Z
--
2.43.0
^ permalink raw reply related
* [PATCH v6 6/7] completion: bisect: complete log opts for visualize subcommand
From: Britton Leo Kerin @ 2024-02-06 21:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Britton Leo Kerin
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
Arguments passed to the "visualize" subcommand of git-bisect(1) get
forwarded to git-log(1). It thus supports the same options as git-log(1)
would, but our Bash completion script does not know to handle this.
Make completion of porcelain git-log options and option arguments to the
visualize subcommand work by calling __git_complete_log_opts when the
start of an option to the subcommand is seen (visualize doesn't support
any options besides the git-log options). Add test.
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 4 ++++
t/t9902-completion.sh | 15 +++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b9ebd5e409..5337ae4ce2 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1490,6 +1490,10 @@ _git_bisect ()
__gitcomp "--term-good --term-old --term-bad --term-new"
return
;;
+ visualize)
+ __git_complete_log_opts
+ return
+ ;;
bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
__git_complete_refs
;;
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 8fcd1cfa7e..b989388e7e 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1361,6 +1361,21 @@ test_expect_success 'git-bisect - options to terms subcommand are candidates' '
)
'
+test_expect_success 'git-bisect - git-log options to visualize subcommand are candidates' '
+ (
+ cd git-bisect &&
+ # The completion used for git-log and here does not complete
+ # every git-log option, so rather than hope to stay in sync
+ # with exactly what it does we will just spot-test here.
+ test_completion "git bisect visualize --sta" <<-\EOF &&
+ --stat Z
+ EOF
+ test_completion "git bisect visualize --summar" <<-\EOF
+ --summary Z
+ EOF
+ )
+'
+
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
HEAD Z
--
2.43.0
^ permalink raw reply related
* Re: [PATCH] Always check the return value of `repo_read_object_file()`
From: Junio C Hamano @ 2024-02-06 22:02 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin
In-Reply-To: <pull.1650.git.1707143753726.gitgitgadget@gmail.com>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index c8e33f97755..982bcfc4b1d 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -571,6 +571,8 @@ static int grep_cache(struct grep_opt *opt,
>
> data = repo_read_object_file(the_repository, &ce->oid,
> &type, &size);
> + if (!data)
> + die(_("unable to read tree %s"), oid_to_hex(&ce->oid));
> init_tree_desc(&tree, data, size);
>
> hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
This caught my attention during today's integration cycle. Checking
nullness for data certainly is an improvement, but shouldn't we be
checking type as well to make sure it is a tree and not a random
tree-ish or even blob?
^ permalink raw reply
* Re: [PATCH 4/4] Always check `parse_tree*()`'s return value
From: Junio C Hamano @ 2024-02-06 22:07 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin
In-Reply-To: <93abd7000b81bbcd7f5422715b4bbb60c69a7cde.1707212981.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> @@ -707,7 +707,8 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
> init_checkout_metadata(&opts.meta, info->refname,
> info->commit ? &info->commit->object.oid : null_oid(),
> NULL);
> - parse_tree(tree);
> + if (parse_tree(tree) < 0)
> + return 128;
> init_tree_desc(&tree_desc, tree->buffer, tree->size);
Another thing that caught my attention during today's integration
cycle was that this "parse the tree object in variable tree and then
call init_tree_desc on it" is a recurring pattern. After the dust
settles, we might want to have a helper function perhaps like
int init_tree_desc_from_tree(struct tree_desc *desc, struct tree *tree)
{
if (parse_tree(tree))
return -1;
init_tree_desc(desc, tree->buffer, tree->size);
}
It was a bit irritating as another topic in flight changes the
function signature for init_tree_desc(), causing a textual conflict
that could be easily avoided.
^ permalink raw reply
* Re: [PATCH v3 4/4] for-each-ref: avoid filtering on empty pattern
From: Karthik Nayak @ 2024-02-06 22:10 UTC (permalink / raw)
To: Junio C Hamano, Phillip Wood; +Cc: phillip.wood, git, ps
In-Reply-To: <xmqqr0hph1ku.fsf@gitster.g>
[-- Attachment #1: Type: text/plain, Size: 2630 bytes --]
Junio C Hamano <gitster@pobox.com> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Phillip Wood <phillip.wood123@gmail.com> writes:
>>
>>> Thanks I'd missed that discussion. I see that at the end of that
>>> discussion Junio was concerned that the proposed "" did not account
>>> for "refs/worktrees/$worktree/*" [1] - how has that been resolved?
>>
>> Ah, that is an excellent point.
>> ...
>> The use of dashed-options to include hierachies that are by default
>> excluded (e.g. "--include-root-refs" and "--include-worktree-refs")
>> feels limiting, but should be sufficient for our needs, both current
>> (i.e. I want to see HEAD and FETCH_HEAD) and in the immediate future
>> (i.e. I want to see worktree refs from that worktree), and I can buy
>> that as a good alternative solution, at least in the shorter term.
>>
>> I still worry that it may make introducing the negative ref patterns
>> harder, though. How does --include-worktree-refs=another to include
>> the worktree refs from another worktree in refs/worktrees/another
>> interact with a negative pattern that was given from the command
>> line that overlaps with it? Whatever interaction rules we define,
>> can we easily explain it in the documentation?
>>
>> Just like "an empty string tells Git to include everything" is a
>> perfectly reasonable approach if we plan to never allow
>> refs/worktrees/ hierarchy, "dashed-options for selected hierarchies"
>> is a perfectly reasonable approach if we plan to never allow
>> negative limit patterns, I suspect. We should stop complexity at
>> some point, and the decision to never support negative limit
>> patterns might be the place to draw that line. I dunno.
>
> For now, let's block the kn/for-all-refs topic until we figure out
> the UI issue. Which means this (and the reftable integration that
> started to depend on it) will not be in the upcoming release.
>
I think it makes sense to remove the kn/for-all-refs topic for now.
I also think that the reftable integration branch can go forward though,
since the difference between v2 and v3 of that series was simply that
v3 was rebased on top of kn/for-all-refs. So we can continue using v2.
> FWIW, I am leaning towards "a set of narrowly targetted command line
> options (like "--include-root-refs")" approach over "a empty string
> defeats the built-in default of 'refs/' limit".
I think this was what the earlier discussion in the RFC series was too,
but Phillip definitely helped consolidate the point.
I'll send a new version of this patch series with `--include-root-refs`
option and we can discuss on top of that.
Thanks all!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply
* Re: [PATCH v3 4/4] for-each-ref: avoid filtering on empty pattern
From: Junio C Hamano @ 2024-02-06 22:16 UTC (permalink / raw)
To: Karthik Nayak; +Cc: Phillip Wood, phillip.wood, git, ps
In-Reply-To: <CAOLa=ZSZJ=_VCppHXcJeE=Z61go4_040xyc1NBTu-o=xysLrdg@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
> I think this was what the earlier discussion in the RFC series was too,
> but Phillip definitely helped consolidate the point.
>
> I'll send a new version of this patch series with `--include-root-refs`
> option and we can discuss on top of that.
Thanks.
By the way, I am not married to the "root refs" name, but
- we do not want to say "all refs", as I expect refs from other
worktrees are not included, and possibly the option when
combined with explicit patterns, like refs/tags/, may further be
used to limit the output;
- we do not want to say "pseudo refs", as I expect we would want to
show HEAD that is (unfortunately) classified outside "pseudoref"
class.
^ permalink raw reply
* Re: git-gui desktop launcher
From: brian m. carlson @ 2024-02-06 22:29 UTC (permalink / raw)
To: Tobias Boesch; +Cc: git
In-Reply-To: <e897282f-ac33-4f1e-903a-b6fb69e0c55e@googlemail.com>
[-- Attachment #1: Type: text/plain, Size: 1270 bytes --]
On 2024-02-06 at 21:14:04, Tobias Boesch wrote:
> 5 Feb 2024 23:29:10 brian m. carlson <sandals@crustytoothpaste.net>:
>
> > It's not guaranteed that bash even exists on the system, let alone that
> > it's in /bin. For example, this wouldn't work on most of the BSDs.
> > This would need to be templated using SHELL_PATH and written in POSIX
> > sh (e.g., no `[[`).
> >
>
> I see. I'll try to look into it. If someone knows how to do that let me know.
>
> >> Icon=/usr/share/git-gui/lib/git-gui.ico
> >
> > This would also need to be given an appropriate location based on the
> > build parameters.
> >
>
> Is it about the build parameters of the build of git(-gui), or about the downstream distros are building?
> So git leaves this empty and the packagers full this out?
No, this would be built by a Makefile target. You'd provide a template
file and adjust it based on something like the `RUNTIME_PREFIX` value,
which is used to adjust locations for data.
There's examples for scripts, such as git-instaweb, which you can use as
an example of how to generate a target file based on the input. This
can also be used to work with `SHELL_PATH` as I mentioned above.
--
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply
* [PATCH v4 0/3] '@' as a synonym for 'HEAD' in patch mode
From: Ghanshyam Thakkar @ 2024-02-06 22:50 UTC (permalink / raw)
To: git; +Cc: gitster, phillip.wood123, ps, Ghanshyam Thakkar
In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com>
Since v3, I have taken Junio's suggestion to replace '@' with 'HEAD'
at the beginning of run_add_p(). Due to this, I no longer think we
need to have/export the_user_meant_head() function just for the single
instance in builtin/checkout.c. Therefore, I have hardcoded the '@'
condition in builtin/checkout.c.
Also, Phillip mentioned that the PERL prerequisites in the test files
that are touched by this series are unnecessary and therefore I have
attached a patch to remove them.
Ghanshyam Thakkar (3):
add-patch: remove unnecessary NEEDSWORK comment
add-patch: classify '@' as a synonym for 'HEAD'
add -p tests: remove Perl prerequisite
add-patch.c | 12 ++++------
builtin/checkout.c | 11 +++++-----
t/t2016-checkout-patch.sh | 46 ++++++++++++++++++++++-----------------
t/t2071-restore-patch.sh | 46 +++++++++++++++++++++------------------
t/t7105-reset-patch.sh | 32 +++++++++++++++++----------
5 files changed, 82 insertions(+), 65 deletions(-)
--
2.43.0
^ permalink raw reply
* [PATCH v4 1/3] add-patch: remove unnecessary NEEDSWORK comment
From: Ghanshyam Thakkar @ 2024-02-06 22:50 UTC (permalink / raw)
To: git; +Cc: gitster, phillip.wood123, ps, Ghanshyam Thakkar
In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com>
The comment suggested to compare commit objects instead of string
comparison to 'HEAD' for supporting more ways of saying 'HEAD' (e.g.
'@'). However, this approach would also count a non-checked out branch
pointing to same commit as HEAD, as HEAD. This would cause confusion to
the user.
Junio described it best as[1]:
"Users may consider 'HEAD' and '@' the same and
may want them to behave the same way, but the user, when explicitly
naming '$branch', means they want to "check contents out of that
OTHER thing named '$branch', not the current branch"; it may or
may not happen to be pointing at the same commit as HEAD, but if
the user meant to say "check contents out of the current commit,
(partially) reverting the local changes I have", the user would have
said HEAD. After all, the user may not even be immediately aware
that '$branch' happens to point at the same commit as HEAD."
[1]: https://lore.kernel.org/git/xmqqmssohu69.fsf@gitster.g/
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
add-patch.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/add-patch.c b/add-patch.c
index 79eda168eb..68f525b35c 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1729,14 +1729,6 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
if (mode == ADD_P_STASH)
s.mode = &patch_mode_stash;
else if (mode == ADD_P_RESET) {
- /*
- * NEEDSWORK: Instead of comparing to the literal "HEAD",
- * compare the commit objects instead so that other ways of
- * saying the same thing (such as "@") are also handled
- * appropriately.
- *
- * This applies to the cases below too.
- */
if (!revision || !strcmp(revision, "HEAD"))
s.mode = &patch_mode_reset_head;
else
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v6 0/7] completion: improvements for git-bisect
From: Junio C Hamano @ 2024-02-06 22:58 UTC (permalink / raw)
To: Britton Leo Kerin; +Cc: git, Patrick Steinhardt
In-Reply-To: <20240206215048.488344-1-britton.kerin@gmail.com>
Britton Leo Kerin <britton.kerin@gmail.com> writes:
> Relative to v5 this makes the following actual changes:
>
> * Treat COMPREPLY as an array on assignment and test, rather than
> relying on the bash mechanism of implicitly acting on the first
> element of the array.
>
> * Whitespace fixes.
>
> The commit message about __git_complete_log_opts has also been changed
> to indicate that COMPREPLY is emptied and why, and a broken
> Signed-off-by line fixed.
Thanks. Let's queue this version and mark it for 'next' by -rc0.
^ permalink raw reply
* [PATCH v4 2/3] add-patch: classify '@' as a synonym for 'HEAD'
From: Ghanshyam Thakkar @ 2024-02-06 22:50 UTC (permalink / raw)
To: git; +Cc: gitster, phillip.wood123, ps, Ghanshyam Thakkar
In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com>
Currently, (checkout, reset, restore) commands correctly take '@' as a
synonym for 'HEAD'. However, in patch mode (-p/--patch), for both '@'
and 'HEAD', different prompts/messages are given by the commands
mentioned above (because of applying reverse mode(-R) in case of '@').
This is due to the literal and only string comparison with the word
'HEAD' in run_add_p(). Synonymity between '@' and 'HEAD' is obviously
desired, especially since '@' already resolves to 'HEAD'.
Therefore, replace '@' to 'HEAD' at the beginning of
add-patch.c:run_add_p(). There is also logic in builtin/checkout.c to
convert all command line input rev to the raw object name for underlying
machinery (e.g., diff-index) that does not recognize the <a>...<b>
notation, but we'd need to leave 'HEAD' intact. Now we need to teach
that '@' is a synonym to 'HEAD' to that code and leave '@' intact, too.
There is one unintended side-effect/behavior change of this, even if
there exists a branch named '@', when providing '@' as a rev-source to
(checkout, reset, restore) commands in patch mode, it will consider it
as HEAD. This is due to the behavior of diff-index. However, naming a
branch '@' is an obvious foot-gun and there are many existing commands
which already take '@' for 'HEAD' regardless of whether 'refs/heads/@'
exists or not (e.g., 'git log @', 'git push origin @' etc.). Therefore,
this should be fine.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
add-patch.c | 4 ++++
builtin/checkout.c | 11 +++++-----
t/t2016-checkout-patch.sh | 46 ++++++++++++++++++++++-----------------
t/t2071-restore-patch.sh | 18 +++++++++------
t/t7105-reset-patch.sh | 10 +++++++++
5 files changed, 57 insertions(+), 32 deletions(-)
diff --git a/add-patch.c b/add-patch.c
index 68f525b35c..6f4ca8f4e4 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1726,6 +1726,10 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
init_add_i_state(&s.s, r);
+ /* helpful in deciding the patch mode ahead */
+ if(revision && !strcmp(revision, "@"))
+ revision = "HEAD";
+
if (mode == ADD_P_STASH)
s.mode = &patch_mode_stash;
else if (mode == ADD_P_RESET) {
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a6e30931b5..79e208ee6d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -539,12 +539,13 @@ static int checkout_paths(const struct checkout_opts *opts,
* recognized by diff-index), we will always replace the name
* with the hex of the commit (whether it's in `...` form or
* not) for the run_add_interactive() machinery to work
- * properly. However, there is special logic for the HEAD case
- * so we mustn't replace that. Also, when we were given a
- * tree-object, new_branch_info->commit would be NULL, but we
- * do not have to do any replacement, either.
+ * properly. However, there is special logic for the 'HEAD' and
+ * '@' case so we mustn't replace that. Also, when we were
+ * given a tree-object, new_branch_info->commit would be NULL,
+ * but we do not have to do any replacement, either.
*/
- if (rev && new_branch_info->commit && strcmp(rev, "HEAD"))
+ if (rev && new_branch_info->commit && strcmp(rev, "HEAD") &&
+ strcmp(rev, "@"))
rev = oid_to_hex_r(rev_oid, &new_branch_info->commit->object.oid);
if (opts->checkout_index && opts->checkout_worktree)
diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh
index 747eb5563e..c4f9bf09aa 100755
--- a/t/t2016-checkout-patch.sh
+++ b/t/t2016-checkout-patch.sh
@@ -38,26 +38,32 @@ test_expect_success 'git checkout -p with staged changes' '
verify_state dir/foo index index
'
-test_expect_success 'git checkout -p HEAD with NO staged changes: abort' '
- set_and_save_state dir/foo work head &&
- test_write_lines n y n | git checkout -p HEAD &&
- verify_saved_state bar &&
- verify_saved_state dir/foo
-'
-
-test_expect_success 'git checkout -p HEAD with NO staged changes: apply' '
- test_write_lines n y y | git checkout -p HEAD &&
- verify_saved_state bar &&
- verify_state dir/foo head head
-'
-
-test_expect_success 'git checkout -p HEAD with change already staged' '
- set_state dir/foo index index &&
- # the third n is to get out in case it mistakenly does not apply
- test_write_lines n y n | git checkout -p HEAD &&
- verify_saved_state bar &&
- verify_state dir/foo head head
-'
+for opt in "HEAD" "@"
+do
+ test_expect_success "git checkout -p $opt with NO staged changes: abort" '
+ set_and_save_state dir/foo work head &&
+ test_write_lines n y n | git checkout -p $opt >output &&
+ verify_saved_state bar &&
+ verify_saved_state dir/foo &&
+ test_grep "Discard" output
+ '
+
+ test_expect_success "git checkout -p $opt with NO staged changes: apply" '
+ test_write_lines n y y | git checkout -p $opt >output &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head &&
+ test_grep "Discard" output
+ '
+
+ test_expect_success "git checkout -p $opt with change already staged" '
+ set_state dir/foo index index &&
+ # the third n is to get out in case it mistakenly does not apply
+ test_write_lines n y n | git checkout -p $opt >output &&
+ verify_saved_state bar &&
+ verify_state dir/foo head head &&
+ test_grep "Discard" output
+ '
+done
test_expect_success 'git checkout -p HEAD^...' '
# the third n is to get out in case it mistakenly does not apply
diff --git a/t/t2071-restore-patch.sh b/t/t2071-restore-patch.sh
index b5c5c0ff7e..dbbefc188d 100755
--- a/t/t2071-restore-patch.sh
+++ b/t/t2071-restore-patch.sh
@@ -44,13 +44,17 @@ test_expect_success PERL 'git restore -p with staged changes' '
verify_state dir/foo index index
'
-test_expect_success PERL 'git restore -p --source=HEAD' '
- set_state dir/foo work index &&
- # the third n is to get out in case it mistakenly does not apply
- test_write_lines n y n | git restore -p --source=HEAD &&
- verify_saved_state bar &&
- verify_state dir/foo head index
-'
+for opt in "HEAD" "@"
+do
+ test_expect_success "git restore -p --source=$opt" '
+ set_state dir/foo work index &&
+ # the third n is to get out in case it mistakenly does not apply
+ test_write_lines n y n | git restore -p --source=$opt >output &&
+ verify_saved_state bar &&
+ verify_state dir/foo head index &&
+ test_grep "Discard" output
+ '
+done
test_expect_success PERL 'git restore -p --source=HEAD^' '
set_state dir/foo work index &&
diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
index 05079c7246..7147148138 100755
--- a/t/t7105-reset-patch.sh
+++ b/t/t7105-reset-patch.sh
@@ -33,6 +33,16 @@ test_expect_success PERL 'git reset -p' '
test_grep "Unstage" output
'
+for opt in "HEAD" "@"
+do
+ test_expect_success "git reset -p $opt" '
+ test_write_lines n y | git reset -p $opt >output &&
+ verify_state dir/foo work head &&
+ verify_saved_state bar &&
+ test_grep "Unstage" output
+ '
+done
+
test_expect_success PERL 'git reset -p HEAD^' '
test_write_lines n y | git reset -p HEAD^ >output &&
verify_state dir/foo work parent &&
--
2.43.0
^ permalink raw reply related
* [PATCH v4 3/3] add -p tests: remove Perl prerequisite
From: Ghanshyam Thakkar @ 2024-02-06 22:50 UTC (permalink / raw)
To: git; +Cc: gitster, phillip.wood123, ps, Ghanshyam Thakkar
In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com>
The Perl version of the add -i/-p commands has been removed since
20b813d (add: remove "add.interactive.useBuiltin" & Perl "git
add--interactive", 2023-02-07)
Therefore, Perl prerequisite in t2071-restore-patch and
t7105-reset-patch is not necessary.
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
t/t2071-restore-patch.sh | 26 +++++++++++++-------------
t/t7105-reset-patch.sh | 22 +++++++++++-----------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/t/t2071-restore-patch.sh b/t/t2071-restore-patch.sh
index dbbefc188d..27e85be40a 100755
--- a/t/t2071-restore-patch.sh
+++ b/t/t2071-restore-patch.sh
@@ -4,7 +4,7 @@ test_description='git restore --patch'
. ./lib-patch-mode.sh
-test_expect_success PERL 'setup' '
+test_expect_success 'setup' '
mkdir dir &&
echo parent >dir/foo &&
echo dummy >bar &&
@@ -16,28 +16,28 @@ test_expect_success PERL 'setup' '
save_head
'
-test_expect_success PERL 'restore -p without pathspec is fine' '
+test_expect_success 'restore -p without pathspec is fine' '
echo q >cmd &&
git restore -p <cmd
'
# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
set_and_save_state dir/foo work head &&
test_write_lines n n | git restore -p &&
verify_saved_state bar &&
verify_saved_state dir/foo
'
-test_expect_success PERL 'git restore -p' '
+test_expect_success 'git restore -p' '
set_and_save_state dir/foo work head &&
test_write_lines n y | git restore -p &&
verify_saved_state bar &&
verify_state dir/foo head head
'
-test_expect_success PERL 'git restore -p with staged changes' '
+test_expect_success 'git restore -p with staged changes' '
set_state dir/foo work index &&
test_write_lines n y | git restore -p &&
verify_saved_state bar &&
@@ -56,7 +56,7 @@ do
'
done
-test_expect_success PERL 'git restore -p --source=HEAD^' '
+test_expect_success 'git restore -p --source=HEAD^' '
set_state dir/foo work index &&
# the third n is to get out in case it mistakenly does not apply
test_write_lines n y n | git restore -p --source=HEAD^ &&
@@ -64,7 +64,7 @@ test_expect_success PERL 'git restore -p --source=HEAD^' '
verify_state dir/foo parent index
'
-test_expect_success PERL 'git restore -p --source=HEAD^...' '
+test_expect_success 'git restore -p --source=HEAD^...' '
set_state dir/foo work index &&
# the third n is to get out in case it mistakenly does not apply
test_write_lines n y n | git restore -p --source=HEAD^... &&
@@ -72,7 +72,7 @@ test_expect_success PERL 'git restore -p --source=HEAD^...' '
verify_state dir/foo parent index
'
-test_expect_success PERL 'git restore -p handles deletion' '
+test_expect_success 'git restore -p handles deletion' '
set_state dir/foo work index &&
rm dir/foo &&
test_write_lines n y | git restore -p &&
@@ -85,21 +85,21 @@ test_expect_success PERL 'git restore -p handles deletion' '
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
# the failure case (and thus get out of the loop).
-test_expect_success PERL 'path limiting works: dir' '
+test_expect_success 'path limiting works: dir' '
set_state dir/foo work head &&
test_write_lines y n | git restore -p dir &&
verify_saved_state bar &&
verify_state dir/foo head head
'
-test_expect_success PERL 'path limiting works: -- dir' '
+test_expect_success 'path limiting works: -- dir' '
set_state dir/foo work head &&
test_write_lines y n | git restore -p -- dir &&
verify_saved_state bar &&
verify_state dir/foo head head
'
-test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
+test_expect_success 'path limiting works: HEAD^ -- dir' '
set_state dir/foo work head &&
# the third n is to get out in case it mistakenly does not apply
test_write_lines y n n | git restore -p --source=HEAD^ -- dir &&
@@ -107,7 +107,7 @@ test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
verify_state dir/foo parent head
'
-test_expect_success PERL 'path limiting works: foo inside dir' '
+test_expect_success 'path limiting works: foo inside dir' '
set_state dir/foo work head &&
# the third n is to get out in case it mistakenly does not apply
test_write_lines y n n | (cd dir && git restore -p foo) &&
@@ -115,7 +115,7 @@ test_expect_success PERL 'path limiting works: foo inside dir' '
verify_state dir/foo head head
'
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
verify_saved_head
'
diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
index 7147148138..3691b94d1b 100755
--- a/t/t7105-reset-patch.sh
+++ b/t/t7105-reset-patch.sh
@@ -5,7 +5,7 @@ test_description='git reset --patch'
TEST_PASSES_SANITIZE_LEAK=true
. ./lib-patch-mode.sh
-test_expect_success PERL 'setup' '
+test_expect_success 'setup' '
mkdir dir &&
echo parent > dir/foo &&
echo dummy > bar &&
@@ -19,14 +19,14 @@ test_expect_success PERL 'setup' '
# note: bar sorts before foo, so the first 'n' is always to skip 'bar'
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
set_and_save_state dir/foo work work &&
test_write_lines n n | git reset -p &&
verify_saved_state dir/foo &&
verify_saved_state bar
'
-test_expect_success PERL 'git reset -p' '
+test_expect_success 'git reset -p' '
test_write_lines n y | git reset -p >output &&
verify_state dir/foo work head &&
verify_saved_state bar &&
@@ -43,28 +43,28 @@ do
'
done
-test_expect_success PERL 'git reset -p HEAD^' '
+test_expect_success 'git reset -p HEAD^' '
test_write_lines n y | git reset -p HEAD^ >output &&
verify_state dir/foo work parent &&
verify_saved_state bar &&
test_grep "Apply" output
'
-test_expect_success PERL 'git reset -p HEAD^^{tree}' '
+test_expect_success 'git reset -p HEAD^^{tree}' '
test_write_lines n y | git reset -p HEAD^^{tree} >output &&
verify_state dir/foo work parent &&
verify_saved_state bar &&
test_grep "Apply" output
'
-test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '
+test_expect_success 'git reset -p HEAD^:dir/foo (blob fails)' '
set_and_save_state dir/foo work work &&
test_must_fail git reset -p HEAD^:dir/foo &&
verify_saved_state dir/foo &&
verify_saved_state bar
'
-test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '
+test_expect_success 'git reset -p aaaaaaaa (unknown fails)' '
set_and_save_state dir/foo work work &&
test_must_fail git reset -p aaaaaaaa &&
verify_saved_state dir/foo &&
@@ -76,27 +76,27 @@ test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
# the failure case (and thus get out of the loop).
-test_expect_success PERL 'git reset -p dir' '
+test_expect_success 'git reset -p dir' '
set_state dir/foo work work &&
test_write_lines y n | git reset -p dir &&
verify_state dir/foo work head &&
verify_saved_state bar
'
-test_expect_success PERL 'git reset -p -- foo (inside dir)' '
+test_expect_success 'git reset -p -- foo (inside dir)' '
set_state dir/foo work work &&
test_write_lines y n | (cd dir && git reset -p -- foo) &&
verify_state dir/foo work head &&
verify_saved_state bar
'
-test_expect_success PERL 'git reset -p HEAD^ -- dir' '
+test_expect_success 'git reset -p HEAD^ -- dir' '
test_write_lines y n | git reset -p HEAD^ -- dir &&
verify_state dir/foo work parent &&
verify_saved_state bar
'
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
verify_saved_head
'
--
2.43.0
^ permalink raw reply related
* [PATCH] restore: allow --staged on unborn branch
From: Ghanshyam Thakkar @ 2024-02-06 23:03 UTC (permalink / raw)
To: git; +Cc: Ghanshyam Thakkar
Some users expect that being on an unborn branch is similar to having an
empty tree checked out. However, when running "git restore --staged ."
on unborn branch having staged changes, the follwing error gets printed,
fatal: could not resolve HEAD
Therefore, teach "git restore --staged ." without a source option, to
take empty tree as source on unborn branch. Note that, this assumption
is already taken by "git reset" (166ec2e9). However, still disallow
explicitly referring to HEAD on unborn branch.
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
builtin/checkout.c | 27 +++++++++++++++++++-------
t/t2073-restore-unborn.sh | 40 +++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 7 deletions(-)
create mode 100755 t/t2073-restore-unborn.sh
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a6e30931b5..1258ae0a59 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1691,6 +1691,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
struct branch_info *new_branch_info)
{
int parseopt_flags = 0;
+ int unborn_and_unspecified = 0;
opts->overwrite_ignore = 1;
opts->prefix = prefix;
@@ -1754,12 +1755,6 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
}
if (opts->checkout_index < 0 || opts->checkout_worktree < 0)
BUG("these flags should be non-negative by now");
- /*
- * convenient shortcut: "git restore --staged [--worktree]" equals
- * "git restore --staged [--worktree] --source HEAD"
- */
- if (!opts->from_treeish && opts->checkout_index)
- opts->from_treeish = "HEAD";
/*
* From here on, new_branch will contain the branch to be checked out,
@@ -1785,6 +1780,18 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
opts->new_branch = argv0 + 1;
}
+ /*
+ * convenient shortcut: "git restore --staged [--worktree]" equals
+ * "git restore --staged [--worktree] --source HEAD"
+ */
+ if (!opts->from_treeish && opts->checkout_index) {
+ struct object_id oid;
+ opts->from_treeish = "HEAD";
+
+ if(repo_get_oid(the_repository, opts->from_treeish, &oid))
+ unborn_and_unspecified = 1;
+ }
+
/*
* Extract branch name from command line arguments, so
* all that is left is pathspecs.
@@ -1812,7 +1819,13 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
} else if (!opts->accept_ref && opts->from_treeish) {
struct object_id rev;
- if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
+ /*
+ * when the branch is unborn and no revision is given, use
+ * empty tree as source
+ */
+ if(unborn_and_unspecified)
+ oidcpy(&rev, the_hash_algo->empty_tree);
+ else if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
die(_("could not resolve %s"), opts->from_treeish);
setup_new_branch_info_and_source_tree(new_branch_info,
diff --git a/t/t2073-restore-unborn.sh b/t/t2073-restore-unborn.sh
new file mode 100755
index 0000000000..fbd8b2df5f
--- /dev/null
+++ b/t/t2073-restore-unborn.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+test_description='restore --staged should work on unborn branch'
+. ./test-lib.sh
+
+test_expect_success 'explicitly naming HEAD on unborn should fail' '
+ echo a >foo &&
+ echo b >bar &&
+ git add foo bar &&
+ test_must_fail git restore --staged --source=HEAD .
+'
+
+test_expect_success 'restore --staged .' '
+ rm .git/index &&
+ git add foo bar &&
+ git restore --staged . &&
+ git diff --cached --name-only >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'restore --staged $file' '
+ rm .git/index &&
+ git add foo bar &&
+ git restore --staged foo &&
+ git diff --cached --name-only >actual &&
+ echo bar >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success 'restore -p --staged' '
+ rm .git/index &&
+ git add foo bar &&
+ test_write_lines y n | git restore -p --staged >output &&
+ git diff --cached --name-only >actual &&
+ echo foo >expected &&
+ test_cmp expected actual &&
+ test_grep "Unstage" output
+'
+
+test_done
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v4 2/3] add-patch: classify '@' as a synonym for 'HEAD'
From: Junio C Hamano @ 2024-02-07 1:05 UTC (permalink / raw)
To: Ghanshyam Thakkar; +Cc: git, phillip.wood123, ps
In-Reply-To: <20240206225122.1095766-6-shyamthakkar001@gmail.com>
Ghanshyam Thakkar <shyamthakkar001@gmail.com> writes:
> Currently, (checkout, reset, restore) commands correctly take '@' as a
> synonym for 'HEAD'. However, in patch mode (-p/--patch), for both '@'
> and 'HEAD', different prompts/messages are given by the commands
> mentioned above (because of applying reverse mode(-R) in case of '@').
> This is due to the literal and only string comparison with the word
> 'HEAD' in run_add_p(). Synonymity between '@' and 'HEAD' is obviously
> desired, especially since '@' already resolves to 'HEAD'.
>
> Therefore, replace '@' to 'HEAD' at the beginning of
> add-patch.c:run_add_p().
Of course there is only one possible downside for this approach, in
that if we are using "revision" in an error message, users who asked
for "@" may complain when an error message says "HEAD" in it. I think
the simplicity of the implementation far outweighs this downside.
> There is also logic in builtin/checkout.c to
> convert all command line input rev to the raw object name for underlying
> machinery (e.g., diff-index) that does not recognize the <a>...<b>
> notation, but we'd need to leave 'HEAD' intact. Now we need to teach
> that '@' is a synonym to 'HEAD' to that code and leave '@' intact, too.
Makes me wonder why we cannot use the same "normalize @ to HEAD
upfront" approach here, though?
It would involve translating "@" given to new_branch_info->name to
"HEAD" early, possibly in setup_new_branch_info_and_source_tree(),
and that probably will fix the other strcmp() with "HEAD" that
appears in builtin/checkout.c:update_refs_for_switch() as well, no?
> + /* helpful in deciding the patch mode ahead */
> + if(revision && !strcmp(revision, "@"))
> + revision = "HEAD";
Style. "if (revision ...)"
^ permalink raw reply
* What's cooking in git.git (Feb 2024, #03; Tue, 6)
From: Junio C Hamano @ 2024-02-07 1:15 UTC (permalink / raw)
To: git
Here are the topics that have been cooking in my tree. Commits
prefixed with '+' are in 'next' (being in 'next' is a sign that a
topic is stable enough to be used and are candidate to be in a
future release). Commits prefixed with '-' are only in 'seen', and
aren't considered "accepted" at all and may be annotated with an URL
to a message that raises issues but they are no means exhaustive. A
topic without enough support may be discarded after a long period of
no activity (of course they can be resubmit when new interests
arise).
Copies of the source code to Git live in many repositories, and the
following is a list of the ones I push into or their mirrors. Some
repositories have only a subset of branches.
With maint, master, next, seen, todo:
git://git.kernel.org/pub/scm/git/git.git/
git://repo.or.cz/alt-git.git/
https://kernel.googlesource.com/pub/scm/git/git/
https://github.com/git/git/
https://gitlab.com/git-vcs/git/
With all the integration branches and topics broken out:
https://github.com/gitster/git/
Even though the preformatted documentation in HTML and man format
are not sources, they are published in these repositories for
convenience (replace "htmldocs" with "manpages" for the manual
pages):
git://git.kernel.org/pub/scm/git/git-htmldocs.git/
https://github.com/gitster/git-htmldocs.git/
Release tarballs are available at:
https://www.kernel.org/pub/software/scm/git/
--------------------------------------------------
[Graduated to 'master']
* cb/use-freebsd-13-2-at-cirrus-ci (2024-01-31) 1 commit
(merged to 'next' on 2024-01-31 at f89dc8a289)
+ ci: update FreeBSD cirrus job
Cirrus CI jobs started breaking because we specified version of
FreeBSD that is no longer available, which has been corrected.
source: <20240131191325.33228-1-carenas@gmail.com>
* jc/comment-style-fixes (2024-01-29) 3 commits
(merged to 'next' on 2024-01-30 at a58d48a9ce)
+ reftable/pq_test: comment style fix
+ merge-ort.c: comment style fix
+ builtin/worktree: comment style fixes
Rewrite //-comments to /* comments */ in files whose comments
prevalently use the latter.
source: <20240129202839.2234084-1-gitster@pobox.com>
* jc/make-libpath-template (2024-01-31) 2 commits
(merged to 'next' on 2024-01-31 at 559d5138bc)
+ Makefile: simplify output of the libpath_template
+ Makefile: reduce repetitive library paths
The Makefile often had to say "-L$(path) -R$(path)" that repeats
the path to the same library directory for link time and runtime.
A Makefile template is used to reduce such repetition.
source: <20240131174220.4160560-1-gitster@pobox.com>
* jc/reftable-core-fsync (2024-01-30) 2 commits
(merged to 'next' on 2024-01-30 at c3a79b6172)
+ reftable/stack: fsync "tables.list" during compaction
(merged to 'next' on 2024-01-24 at cea12beddb)
+ reftable: honor core.fsync
(this branch is used by ps/reftable-multi-level-indices-fix.)
The write codepath for the reftable data learned to honor
core.fsync configuration.
source: <7bdafc9bd7f53f38a24d69a563615b6ad484e1ba.1706592127.git.ps@pks.im>
* jc/t0091-with-unknown-git (2024-01-30) 1 commit
(merged to 'next' on 2024-01-31 at 3dfcad1b18)
+ t0091: allow test in a repository without tags
The test did not work when Git was built from a repository without
tags.
source: <xmqqv87aabk3.fsf@gitster.g>
* jk/diff-external-with-no-index (2024-01-29) 1 commit
(merged to 'next' on 2024-01-30 at 30c3e9f91d)
+ diff: handle NULL meta-info when spawning external diff
"git diff --no-index file1 file2" segfaulted while invoking the
external diff driver, which has been corrected.
source: <20240129015708.GA1762343@coredump.intra.peff.net>
* js/win32-retry-pipe-write-on-enospc (2024-01-30) 1 commit
(merged to 'next' on 2024-01-31 at 60ad589fd0)
+ win32: special-case `ENOSPC` when writing to a pipe
Update to the code that writes to pipes on Windows.
source: <pull.1648.git.1706650619950.gitgitgadget@gmail.com>
* jt/p4-spell-re-with-raw-string (2024-01-29) 1 commit
(merged to 'next' on 2024-01-30 at 42b03b58eb)
+ git-p4: use raw string literals for regular expressions
"git p4" update to squelch warnings from Python.
source: <pull.1639.v2.git.1706312496608.gitgitgadget@gmail.com>
* kh/maintenance-use-xdg-when-it-should (2024-01-29) 1 commit
(merged to 'next' on 2024-01-30 at c449ac74bf)
+ config: add back code comment
Comment fix.
source: <48d66e94ece3b763acbe933561d82157c02a5f58.1706466321.git.code@khaugsbakk.name>
* ps/reftable-compacted-tables-permission-fix (2024-01-26) 1 commit
(merged to 'next' on 2024-01-29 at dbb06e1571)
+ reftable/stack: adjust permissions of compacted tables
Reftable bugfix.
source: <a211818108053754aca002726d0206623a347952.1706263589.git.ps@pks.im>
* ps/tests-with-ref-files-backend (2024-01-29) 6 commits
(merged to 'next' on 2024-01-30 at 376b9c9c1b)
+ t: mark tests regarding git-pack-refs(1) to be backend specific
+ t5526: break test submodule differently
+ t1419: mark test suite as files-backend specific
+ t1302: make tests more robust with new extensions
+ t1301: mark test for `core.sharedRepository` as reffiles specific
+ t1300: make tests more robust with non-default ref backends
(this branch is used by ps/reftable-backend.)
Prepare existing tests on refs to work better with non-default
backends.
source: <cover.1706525813.git.ps@pks.im>
* rj/test-with-leak-check (2024-01-29) 4 commits
(merged to 'next' on 2024-01-31 at 76e4596666)
+ t0080: mark as leak-free
+ test-lib: check for TEST_PASSES_SANITIZE_LEAK
+ t6113: mark as leak-free
+ t5332: mark as leak-free
More tests that are supposed to pass leak sanitizer are marked as such.
source: <45eb0748-6415-4e52-a54f-8d4e5ad57dde@gmail.com>
* tb/pack-bitmap-drop-unused-struct-member (2024-01-29) 1 commit
(merged to 'next' on 2024-01-30 at f3749b15fc)
+ pack-bitmap: drop unused `reuse_objects`
Code clean-up.
source: <0bbaf9a3591765161872fb71383263edb0c7ef83.1706328008.git.me@ttaylorr.com>
--------------------------------------------------
[New Topics]
* gt/at-is-synonym-for-head-in-add-patch (2024-02-03) 3 commits
- SQUASH???
- add-patch: classify '@' as a synonym for 'HEAD'
- add-patch: remove unnecessary NEEDSWORK comment
Teach "git checkout -p" and friends that "@" is a synonym for
"HEAD".
source: <20240202150434.11256-1-shyamthakkar001@gmail.com>
* js/unit-test-suite-runner (2024-02-03) 7 commits
- t/Makefile: run unit tests alongside shell tests
- unit tests: add rule for running with test-tool
- test-tool run-command testsuite: support unit tests
- test-tool run-command testsuite: remove hardcoded filter
- test-tool run-command testsuite: get shell from env
- t0080: turn t-basic unit test into a helper
- Merge branch 'jk/unit-tests-buildfix' into js/unit-test-suite-runner
(this branch uses jk/unit-tests-buildfix.)
The "test-tool" has been taught to run testsuite tests in parallel,
bypassing the need to use the "prove" tool.
source: <cover.1706921262.git.steadmon@google.com>
* jc/sign-buffer-failure-propagation-fix (2024-02-06) 1 commit
- tag: fix sign_buffer() call to create a signed tag
* js/check-null-from-read-object-file (2024-02-06) 1 commit
- Always check the return value of `repo_read_object_file()`
source: <pull.1650.git.1707143753726.gitgitgadget@gmail.com>
* pb/template-for-single-commit-pr (2024-02-06) 1 commit
- .github/PULL_REQUEST_TEMPLATE.md: add a note about single-commit PRs
source: <pull.1665.v2.git.git.1707225612576.gitgitgadget@gmail.com>
* ps/report-failure-from-git-stash (2024-02-06) 1 commit
- builtin/stash: report failure to write to index
source: <cb098cf88cbfcbf7c4872f8887856629b909cb91.1707197653.git.ps@pks.im>
* tb/multi-pack-reuse-experiment (2024-02-05) 2 commits
- pack-objects: enable multi-pack reuse via `feature.experimental`
- t5332-multi-pack-reuse.sh: extract pack-objects helper functions
source: <cover.1707173415.git.me@ttaylorr.com>
--------------------------------------------------
[Cooking]
* ps/reftable-backend (2024-02-02) 3 commits
- ci: add jobs to test with the reftable backend
- refs: introduce reftable backend
- Merge branch 'ps/tests-with-ref-files-backend' into ps/reftable-backend
Integrate the reftable code into the refs framework as a backend.
Will merge to 'next'.
source: <cover.1706862705.git.ps@pks.im>
* cc/rev-list-allow-missing-tips (2024-02-01) 3 commits
- rev-list: add --allow-missing-tips to be used with --missing=...
- t6022: fix 'even though' typo in comment
- revision: clarify a 'return NULL' in get_reference()
"git rev-list --missing=print" have learned to optionally take
"--allow-missing-tips", which allows the objects at the starting
points to be missing.
Needs review.
source: <20240201115809.1177064-1-christian.couder@gmail.com>
* ps/reftable-iteration-perf (2024-02-01) 7 commits
- reftable/reader: add comments to `table_iter_next()`
- reftable/record: don't try to reallocate ref record name
- reftable/block: swap buffers instead of copying
- reftable/pq: allocation-less comparison of entry keys
- reftable/merged: skip comparison for records of the same subiter
- reftable/merged: allocation-less dropping of shadowed records
- reftable/record: introduce function to compare records by key
The code to iterate over refs with the reftable backend has seen
some optimization.
Needs review.
source: <cover.1706782841.git.ps@pks.im>
* ps/reftable-styles (2024-02-06) 9 commits
- reftable/record: improve semantics when initializing records
- reftable/merged: refactor initialization of iterators
- reftable/merged: refactor seeking of records
- reftable/stack: use `size_t` to track stack length
- reftable/stack: use `size_t` to track stack slices during compaction
- reftable/stack: index segments with `size_t`
- reftable/stack: fix parameter validation when compacting range
- reftable: introduce macros to allocate arrays
- reftable: introduce macros to grow arrays
Code clean-up in various reftable code paths.
Will merge to 'next'.
source: <cover.1707200355.git.ps@pks.im>
* pb/imap-send-wo-curl-build-fix (2024-02-01) 1 commit
(merged to 'next' on 2024-02-05 at 18368f61a7)
+ imap-send: add missing "strbuf.h" include under NO_CURL
Build fix.
Will merge to 'master'.
source: <pull.1664.git.git.1706833113569.gitgitgadget@gmail.com>
* jc/github-actions-update (2024-02-02) 1 commit
- Merge branch 'jc/maint-github-actions-update' into jc/github-actions-update
(this branch uses jc/maint-github-actions-update.)
An evil merge of the other topic to a more modern codebase.
Will merge to 'next'?
* jc/maint-github-actions-update (2024-02-02) 2 commits
- GitHub Actions: update to github-script@v7
- GitHub Actions: update to checkout@v4
(this branch is used by jc/github-actions-update.)
Squelch node.js 16 deprecation warnings from GitHub Actions CI
by updating actions/github-script and actions/checkout that use
node.js 20.
Needs review.
source: <20240202203935.1240458-1-gitster@pobox.com>
* jh/sparse-index-expand-to-path-fix (2024-02-02) 1 commit
(merged to 'next' on 2024-02-06 at 17ec59dd9a)
+ sparse-index: pass string length to index_file_exists()
A caller called index_file_exists() that takes a string expressed
as <ptr, length> with a wrong length, which has been corrected.
Will merge to 'master'.
source: <pull.1649.git.1706897095273.gitgitgadget@gmail.com>
* jk/unit-tests-buildfix (2024-02-02) 4 commits
(merged to 'next' on 2024-02-02 at 8838dd21e8)
+ t/Makefile: say the default target upfront
(merged to 'next' on 2024-01-31 at 00df31c4c8)
+ t/Makefile: get UNIT_TESTS list from C sources
+ Makefile: remove UNIT_TEST_BIN directory with "make clean"
+ Makefile: use mkdir_p_parent_template for UNIT_TEST_BIN
(this branch is used by js/unit-test-suite-runner.)
Build dependency around unit tests has been fixed.
Will merge to 'master'.
source: <20240130053714.GA165967@coredump.intra.peff.net>
source: <xmqqjznmtjr9.fsf@gitster.g>
* js/merge-tree-3-trees (2024-02-06) 5 commits
- Always check `parse_tree*()`'s return value
- t4301: verify that merge-tree fails on missing blob objects
- merge-ort: do check `parse_tree()`'s return value
- merge-tree: fail with a non-zero exit code on missing tree objects
(merged to 'next' on 2024-01-30 at 0c77b04e59)
+ merge-tree: accept 3 trees as arguments
"git merge-tree" has learned that the three trees involved in the
3-way merge only need to be trees, not necessarily commits.
Will cook in 'next'
source: <pull.1647.v2.git.1706474063109.gitgitgadget@gmail.com>
source: <pull.1651.git.1707212981.gitgitgadget@gmail.com>
* mh/credential-oauth-refresh-token-with-wincred (2024-01-29) 1 commit
(merged to 'next' on 2024-02-05 at 68880a751a)
+ credential/wincred: store oauth_refresh_token
Teach wincred credential backend to support oauth refresh token the
same way as credential-cache and credential-libsecret backends.
Will merge to 'master'.
source: <pull.1534.v3.git.1706477103039.gitgitgadget@gmail.com>
* pb/complete-config (2024-01-29) 5 commits
- completion: add an use _ _git_compute_second_level_config_vars_for_section
- builtin/help: add --config-all-for-completion
- completion: add and use _ _git_compute_first_level_config_vars_for_section
- completion: complete 'submodule.*' config variables
- completion: add space after config variable names also in Bash 3
The command line completion script (in contrib/) learned to
complete configuration variable names better.
Needs review.
source: <pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com>
* rj/complete-reflog (2024-01-26) 4 commits
- completion: reflog show <log-options>
- completion: reflog with implicit "show"
- completion: introduce __git_find_subcommand
- completion: introduce __gitcomp_subcommand
The command line completion script (in contrib/) learned to
complete "git reflog" better.
Needs review.
source: <98daf977-dbad-4d3b-a293-6a769895088f@gmail.com>
* jc/index-pack-fsck-levels (2024-02-01) 2 commits
(merged to 'next' on 2024-02-02 at 0e4ef26aa1)
+ index-pack: --fsck-objects to take an optional argument for fsck msgs
+ index-pack: test and document --strict=<msg-id>=<severity>...
The "--fsck-objects" option of "git index-pack" now can take the
optional parameter to tweak severity of different fsck errors.
Will merge to 'master'.
source: <pull.1658.v4.git.git.1706751483.gitgitgadget@gmail.com>
* ps/reftable-multi-level-indices-fix (2024-02-01) 6 commits
- reftable: document reading and writing indices
- reftable/writer: fix writing multi-level indices
- reftable/writer: simplify writing index records
- reftable/writer: use correct type to iterate through index entries
- reftable/reader: be more careful about errors in indexed seeks
- Merge branch 'jc/reftable-core-fsync' into ps/reftable-multi-level-indices-fix
Write multi-level indices for reftable has been corrected.
Will merge to 'next'.
source: <cover.1706773842.git.ps@pks.im>
* cp/unit-test-prio-queue (2024-01-22) 1 commit
(merged to 'next' on 2024-02-01 at 38aa6559b0)
+ tests: move t0009-prio-queue.sh to the new unit testing framework
Migrate priority queue test to unit testing framework.
Will merge to 'master'.
source: <pull.1642.v4.git.1705865326185.gitgitgadget@gmail.com>
* ml/log-merge-with-cherry-pick-and-other-pseudo-heads (2024-01-17) 2 commits
- revision: implement `git log --merge` also for rebase/cherry_pick/revert
- revision: ensure MERGE_HEAD is a ref in prepare_show_merge
"git log --merge" learned to pay attention to CHERRY_PICK_HEAD and
other kinds of *_HEAD pseudorefs.
Comments?
source: <xmqqzfxa9usx.fsf@gitster.g>
* bk/complete-bisect (2024-01-29) 9 commits
- SQUASH???
- completion: add tests for git-bisect
- completion: bisect: recognize but do not complete view subcommand
- completion: bisect: complete log opts for visualize subcommand
- completion: log: use __git_complete_log_opts
- completion: new function __git_complete_log_opts
- completion: bisect: complete missing --first-parent and --no-checkout options
- completion: bisect: complete custom terms and related options
- completion: bisect: complete bad, new, old, and help subcommands
Command line completion support (in contrib/) has been
updated for "git bisect".
Comments?
cf. <ZaofJhHsFjRxx7a3@tanuki>
source: <20240128223447.342493-1-britton.kerin@gmail.com>
* bk/complete-dirname-for-am-and-format-patch (2024-01-12) 1 commit
- completion: dir-type optargs for am, format-patch
Command line completion support (in contrib/) has been
updated for a few commands to complete directory names where a
directory name is expected.
Needs review.
source: <d37781c3-6af2-409b-95a8-660a9b92d20b@smtp-relay.sendinblue.com>
* bk/complete-send-email (2024-01-12) 1 commit
- completion: don't complete revs when --no-format-patch
Command line completion support (in contrib/) has been taught to
avoid offering revision names as candidates to "git send-email" when
the command is used to send pre-generated files.
Needs review.
source: <a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>
* la/trailer-api (2024-02-06) 28 commits
- trailer: introduce "template" term for readability
- trailer_set_*(): put out parameter at the end
- trailer: unify "--trailer ..." arg handling
- trailer: deprecate "new_trailer_item" struct from API
- trailer_add_arg_item(): drop new_trailer_item usage
- trailer: add new helper functions to API
- trailer: prepare to delete "parse_trailers_from_command_line_args()"
- trailer: spread usage of "trailer_block" language
- trailer: retire trailer_info_get() from API
- trailer: make trailer_info struct private
- sequencer: use the trailer iterator
- trailer: teach iterator about non-trailer lines
- trailer: finish formatting unification
- format_trailer_info(): avoid double-printing the separator
- format_trailer_info(): teach it about opts->trim_empty
- trailer: begin formatting unification
- format_trailer_info(): append newline for non-trailer lines
- format_trailer_info(): drop redundant unfold_value()
- format_trailer_info(): use trailer_item objects
- format_trailers_from_commit(): indirectly call trailer_info_get()
- format_trailer_info(): move "fast path" to caller
- format_trailers(): use strbuf instead of FILE
- trailer_info_get(): reorder parameters
- trailer: start preparing for formatting unification
- trailer: move interpret_trailers() to interpret-trailers.c
- trailer: prepare to expose functions as part of API
- shortlog: add test for de-duplicating folded trailers
- trailer: free trailer_info _after_ all related usage
Code clean-up.
Needs review.
source: <pull.1632.v4.git.1707196348.gitgitgadget@gmail.com>
* cp/apply-core-filemode (2023-12-26) 3 commits
- apply: code simplification
- apply: correctly reverse patch's pre- and post-image mode bits
- apply: ignore working tree filemode when !core.filemode
"git apply" on a filesystem without filemode support have learned
to take a hint from what is in the index for the path, even when
not working with the "--index" or "--cached" option, when checking
the executable bit match what is required by the preimage in the
patch.
Needs review.
source: <20231226233218.472054-1-gitster@pobox.com>
* ja/doc-placeholders-fix (2023-12-26) 2 commits
(merged to 'next' on 2024-02-05 at 047da8cbb0)
+ doc: enforce placeholders in documentation
+ doc: enforce dashes in placeholders
Docfix.
Will merge to 'master'.
source: <pull.1626.git.1703539287.gitgitgadget@gmail.com>
* jc/bisect-doc (2023-12-09) 1 commit
- bisect: document "terms" subcommand more fully
Doc update.
Needs review.
source: <xmqqzfyjmk02.fsf@gitster.g>
* tb/path-filter-fix (2024-01-31) 16 commits
- bloom: introduce `deinit_bloom_filters()`
- commit-graph: reuse existing Bloom filters where possible
- object.h: fix mis-aligned flag bits table
- commit-graph: new Bloom filter version that fixes murmur3
- commit-graph: unconditionally load Bloom filters
- bloom: prepare to discard incompatible Bloom filters
- bloom: annotate filters with hash version
- repo-settings: introduce commitgraph.changedPathsVersion
- t4216: test changed path filters with high bit paths
- t/helper/test-read-graph: implement `bloom-filters` mode
- bloom.h: make `load_bloom_filter_from_graph()` public
- t/helper/test-read-graph.c: extract `dump_graph_info()`
- gitformat-commit-graph: describe version 2 of BDAT
- commit-graph: ensure Bloom filters are read with consistent settings
- revision.c: consult Bloom filters for root commits
- t/t4216-log-bloom.sh: harden `test_bloom_filters_not_used()`
The Bloom filter used for path limited history traversal was broken
on systems whose "char" is unsigned; update the implementation and
bump the format version to 2.
Waiting for a final ack?
cf. <ZcFjkfbsBfk7JQIH@nand.local>
source: <cover.1706741516.git.me@ttaylorr.com>
* ak/color-decorate-symbols (2023-10-23) 7 commits
- log: add color.decorate.pseudoref config variable
- refs: exempt pseudorefs from pattern prefixing
- refs: add pseudorefs array and iteration functions
- log: add color.decorate.ref config variable
- log: add color.decorate.symbol config variable
- log: use designated inits for decoration_colors
- config: restructure color.decorate documentation
A new config for coloring.
Needs review.
source: <20231023221143.72489-1-andy.koppe@gmail.com>
* eb/hash-transition (2023-10-02) 30 commits
- t1016-compatObjectFormat: add tests to verify the conversion between objects
- t1006: test oid compatibility with cat-file
- t1006: rename sha1 to oid
- test-lib: compute the compatibility hash so tests may use it
- builtin/ls-tree: let the oid determine the output algorithm
- object-file: handle compat objects in check_object_signature
- tree-walk: init_tree_desc take an oid to get the hash algorithm
- builtin/cat-file: let the oid determine the output algorithm
- rev-parse: add an --output-object-format parameter
- repository: implement extensions.compatObjectFormat
- object-file: update object_info_extended to reencode objects
- object-file-convert: convert commits that embed signed tags
- object-file-convert: convert commit objects when writing
- object-file-convert: don't leak when converting tag objects
- object-file-convert: convert tag objects when writing
- object-file-convert: add a function to convert trees between algorithms
- object: factor out parse_mode out of fast-import and tree-walk into in object.h
- cache: add a function to read an OID of a specific algorithm
- tag: sign both hashes
- commit: export add_header_signature to support handling signatures on tags
- commit: convert mergetag before computing the signature of a commit
- commit: write commits for both hashes
- object-file: add a compat_oid_in parameter to write_object_file_flags
- object-file: update the loose object map when writing loose objects
- loose: compatibilty short name support
- loose: add a mapping between SHA-1 and SHA-256 for loose objects
- repository: add a compatibility hash algorithm
- object-names: support input of oids in any supported hash
- oid-array: teach oid-array to handle multiple kinds of oids
- object-file-convert: stubs for converting from one object format to another
Teach a repository to work with both SHA-1 and SHA-256 hash algorithms.
Needs review.
source: <878r8l929e.fsf@gmail.froward.int.ebiederm.org>
* jc/rerere-cleanup (2023-08-25) 4 commits
- rerere: modernize use of empty strbuf
- rerere: try_merge() should use LL_MERGE_ERROR when it means an error
- rerere: fix comment on handle_file() helper
- rerere: simplify check_one_conflict() helper function
Code clean-up.
Not ready to be reviewed yet.
source: <20230824205456.1231371-1-gitster@pobox.com>
--------------------------------------------------
[Discarded]
* tb/pair-chunk-expect (2023-11-10) 8 commits
. midx: read `OOFF` chunk with `pair_chunk_expect()`
. midx: read `OIDL` chunk with `pair_chunk_expect()`
. commit-graph: read `BIDX` chunk with `pair_chunk_expect()`
. commit-graph: read `GDAT` chunk with `pair_chunk_expect()`
. commit-graph: read `CDAT` chunk with `pair_chunk_expect()`
. commit-graph: read `OIDL` chunk with `pair_chunk_expect()`
. chunk-format: introduce `pair_chunk_expect()` helper
. Merge branch 'jk/chunk-bounds-more' into HEAD
Further code clean-up.
Retracted for now.
cf. <ZcFjkfbsBfk7JQIH@nand.local>
source: <cover.1699569246.git.me@ttaylorr.com>
* kn/for-all-refs (2024-01-29) 4 commits
(merged to 'next' on 2024-01-30 at e7a9234a8b)
+ for-each-ref: avoid filtering on empty pattern
+ refs: introduce `refs_for_each_all_refs()`
+ refs: extract out `loose_fill_ref_dir_regular_file()`
+ refs: introduce `is_pseudoref()` and `is_headref()`
"git for-each-ref" filters its output with prefixes given from the
command line, but it did not honor an empty string to mean "pass
everything", which has been corrected.
Reverted out of 'next' to revamp its UI.
source: <20240129113527.607022-1-karthik.188@gmail.com>
^ permalink raw reply
* Re: [PATCH v3 1/4] refs: introduce `is_pseudoref()` and `is_headref()`
From: Jeff King @ 2024-02-07 1:48 UTC (permalink / raw)
To: Karthik Nayak; +Cc: git, gitster, ps, phillip.wood123
In-Reply-To: <20240129113527.607022-2-karthik.188@gmail.com>
On Mon, Jan 29, 2024 at 12:35:24PM +0100, Karthik Nayak wrote:
> +int is_pseudoref(struct ref_store *refs, const char *refname)
> [...]
> + if (ends_with(refname, "_HEAD")) {
> + read_ref_full(refname, RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
> + &oid, NULL);
> + return !is_null_oid(&oid);
> + }
I was going to prepare a patch on top, but since it looks like this was
reverted out of 'next' to be revamped, I thought I'd mention it now:
-Wunused-parameter notices that we never use the "refs" parameter to the
function. And indeed it looks like a (possible) bug, since
read_ref_full() is going to use the_repository to find the ref store.
I think you'd want something like this squashed in (note that it also
fixes a slight indent problem in the first block):
diff --git a/refs.c b/refs.c
index 3190df8d81..0d65c31117 100644
--- a/refs.c
+++ b/refs.c
@@ -875,15 +875,17 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
return 0;
if (ends_with(refname, "_HEAD")) {
- read_ref_full(refname, RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
- &oid, NULL);
- return !is_null_oid(&oid);
+ refs_resolve_ref_unsafe(refs, refname,
+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+ &oid, NULL);
+ return !is_null_oid(&oid);
}
for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++)
if (!strcmp(refname, irregular_pseudorefs[i])) {
- read_ref_full(refname, RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
- &oid, NULL);
+ refs_resolve_ref_unsafe(refs, refname,
+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+ &oid, NULL);
return !is_null_oid(&oid);
}
-Peff
^ permalink raw reply related
* Re: [PATCH v6 0/7] completion: improvements for git-bisect
From: Patrick Steinhardt @ 2024-02-07 5:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Britton Leo Kerin, git
In-Reply-To: <xmqq8r3xfbep.fsf@gitster.g>
[-- Attachment #1: Type: text/plain, Size: 748 bytes --]
On Tue, Feb 06, 2024 at 02:58:06PM -0800, Junio C Hamano wrote:
> Britton Leo Kerin <britton.kerin@gmail.com> writes:
>
> > Relative to v5 this makes the following actual changes:
> >
> > * Treat COMPREPLY as an array on assignment and test, rather than
> > relying on the bash mechanism of implicitly acting on the first
> > element of the array.
> >
> > * Whitespace fixes.
> >
> > The commit message about __git_complete_log_opts has also been changed
> > to indicate that COMPREPLY is emptied and why, and a broken
> > Signed-off-by line fixed.
>
> Thanks. Let's queue this version and mark it for 'next' by -rc0.
The range-diff looks good to me indeed, so I agree that this can be
queued. Thanks!
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: Query about gitignore
From: Patrick Steinhardt @ 2024-02-07 5:43 UTC (permalink / raw)
To: Divyaditya Singh; +Cc: git
In-Reply-To: <B7F364DA-27E7-4BDC-93EE-32E6430B6ACE@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
Hi Divyaditya,
On Wed, Feb 07, 2024 at 01:56:34AM +0530, Divyaditya Singh wrote:
> Hello there,
>
> I hope you are having a wonderful day.
>
> I apologize if this is inappropriate but I wanted to ask is there a
> way that I can make my .gitignore such that it ignores the entire
> parent directory of a matching file.
Not inappropriate at all!
Rephrasing what you say, you basically want to ignore "dir/" if and only
if "dir/a" exists and matches a specific pattern in your gitignore,
right? If so, this is not something that you can currently achieve with
gitignores.
Would you mind maybe explaining your particular usecase a bit more? This
_could_ help to find a different solution for you. But even if there is
none it might motivate others to think about possible ways to implement
this in Git if there is interest.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* GitGui tool - new local clone is missing commit(s) and missing a tag on master branch
From: Allan Ford @ 2024-02-07 6:00 UTC (permalink / raw)
To: git@vger.kernel.org
Dear Git devs,
GitGui tool local clone is missing commit(s) and missing a tag on master branch
As compared to using Visual Studio 2022 or Visual Studio Code ..
Wondering if a bug somehow / somewhere ?
Other colleague devs observe the same ..
If I switch to the remote master branch then I get right content .. but I should be able to do a new clone of master and hold locally.
I have trusted GitGui tool and it's new repo clone for years .. but it has let me down this time ..
Kind Regards,
Allan
Allan Ford
Application Developer
email: allan.ford@hambs.com.au
www.hambs.com.au
^ permalink raw reply
* [PATCH v4 0/2] refs: introduce reftable backend
From: Patrick Steinhardt @ 2024-02-07 7:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Han-Wen Nienhuys, Karthik Nayak
In-Reply-To: <cover.1706601199.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 5421 bytes --]
Hi,
this is the fourth version of my patch series that introduces the
reftable backend.
Changes compared to v3:
- kn/for-all-refs has been reverted due to discussions around its user
interface. I have thus evicted the patch series as a dependency and
dropped handling of DO_FOR_EACH_INCLUDE_ALL_REFS.
- ps/reftable-compacted-tables-permission-fix has been merged to
"master" now, fixing permissions on "tables.list" when compacting
reftables. I've marked the corresponding test as succeeding.
- jc/reftable-core-fsync has been merged to "master" now, which adds
fsyncing logic to reftable. I've marked the corresponding test as
succeeding.
- I noticed that the fsync tests fail on macOS because there we use a
different fsync method by default. I fixed that by explicitly saying
which fsync method should be used in the corresponding tests.
- I also noticed that the second fsync test reused "trace2.txt" from
the first fsync test because it only appends to the file. Thus, we
saw two fsync events instead of one. I fixed that by truncating the
file.
The patch series is based on the current "master" branch at 235986be82
(The fourteenth batch, 2024-02-06).
Thanks!
Patrick
Patrick Steinhardt (2):
refs: introduce reftable backend
ci: add jobs to test with the reftable backend
.github/workflows/main.yml | 9 +
.gitlab-ci.yml | 9 +
Documentation/ref-storage-format.txt | 2 +
.../technical/repository-version.txt | 5 +-
Makefile | 1 +
ci/lib.sh | 2 +-
ci/run-build-and-tests.sh | 3 +
contrib/workdir/git-new-workdir | 2 +-
path.c | 2 +-
path.h | 1 +
refs.c | 1 +
refs/refs-internal.h | 1 +
refs/reftable-backend.c | 2297 +++++++++++++++++
repository.h | 5 +-
t/t0610-reftable-basics.sh | 887 +++++++
t/t0611-reftable-httpd.sh | 26 +
t/test-lib.sh | 2 +
17 files changed, 3248 insertions(+), 7 deletions(-)
create mode 100644 refs/reftable-backend.c
create mode 100755 t/t0610-reftable-basics.sh
create mode 100755 t/t0611-reftable-httpd.sh
Range-diff against v3:
1: d83e66e980 ! 1: 5de60d46bd refs: introduce reftable backend
@@ refs/reftable-backend.c (new)
+ break;
+
+ /*
-+ * Unless DO_FOR_EACH_INCLUDE_ALL_REFS is set, we only list
-+ * refs starting with "refs/" to mimic the "files" backend.
++ * The files backend only lists references contained in
++ * "refs/". We emulate the same behaviour here and thus skip
++ * all references that don't start with this prefix.
+ */
-+ if (!(iter->flags & DO_FOR_EACH_INCLUDE_ALL_REFS) &&
-+ !starts_with(iter->ref.refname, "refs/"))
++ if (!starts_with(iter->ref.refname, "refs/"))
+ continue;
+
+ if (iter->prefix &&
@@ t/t0610-reftable-basics.sh (new)
+ test_cmp expect actual
+}
+
-+# A fix for this is in flight via jc/reftable-core-fsync.
-+test_expect_failure 'ref transaction: writes are synced' '
++test_expect_success 'ref transaction: writes are synced' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo initial &&
+
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+ GIT_TEST_FSYNC=true \
-+ git -C repo -c core.fsync=reference update-ref refs/heads/branch HEAD &&
++ git -C repo -c core.fsync=reference \
++ -c core.fsyncMethod=fsync update-ref refs/heads/branch HEAD &&
+ check_fsync_events trace2.txt <<-EOF
+ "name":"hardware-flush","count":2
+ EOF
@@ t/t0610-reftable-basics.sh (new)
+
+for umask in 002 022
+do
-+ # A fix for this is in flight via ps/reftable-compacted-tables-permission-fix.
-+ test_expect_failure POSIXPERM 'pack-refs: honors core.sharedRepository' '
++ test_expect_success POSIXPERM 'pack-refs: honors core.sharedRepository' '
+ test_when_finished "rm -rf repo" &&
+ (
+ umask $umask &&
@@ t/t0610-reftable-basics.sh (new)
+ '
+done
+
-+# A fix for this is in flight.
-+test_expect_failure 'packed-refs: writes are synced' '
++test_expect_success 'packed-refs: writes are synced' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo initial &&
+ test_line_count = 2 table-files &&
+
++ : >trace2.txt &&
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+ GIT_TEST_FSYNC=true \
-+ git -C repo -c core.fsync=reference pack-refs &&
++ git -C repo -c core.fsync=reference \
++ -c core.fsyncMethod=fsync pack-refs &&
+ check_fsync_events trace2.txt <<-EOF
+ "name":"hardware-flush","count":2
+ EOF
2: 146bb95c03 = 2: 30e5feb28c ci: add jobs to test with the reftable backend
base-commit: 235986be822c9f8689be2e9a0b7804d0b1b6d821
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox