* Re: [PATCH] rebase -i: allow a comment after a "break" command
From: Elijah Newren @ 2023-01-14 2:47 UTC (permalink / raw)
To: Junio C Hamano
Cc: Ævar Arnfjörð Bjarmason,
Phillip Wood via GitGitGadget, git, Olliver Schinagl,
Johannes Schindelin, Phillip Wood, Christian Couder
In-Reply-To: <xmqqwn5q1960.fsf@gitster.g>
On Fri, Jan 13, 2023 at 12:17 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
> > Of course, the same applies to edit/squash/fixup/reword, though if I
> > could go back in time...(warning, long tangent coming)...I would make
> > it so those four directives did not accept any commit ID argument.
> > Only "pick" and "reset" would accept a commit ID. Instead, today's
> > "edit X" would be two commands ("pick X" followed by either "break" or
> > "edit"), "fixup X" would be "pick X" + "fixup", and "reword X" would
> > be "pick X" + "reword". That'd help users understand rebase state
> > much better (it's so easy for users to get confused by whether they
> > should be using `git commit --amend` vs. `git rebase --continue` and I
> > think this is partially to blame, though there's other changes we
> > could make to help with that dichotomy as well). The separate
> > directives would also make it much easier to figure out how to both
> > fixup and edit a single commit in the same rebase (pick the commit,
> > then add a fixup directive, then an edit directive).
>
> Intriguing, and I feel sad that it probably is too late for all of
> the above X-<.
Yeah, I know. One more thing for the "if we had a time machine" list...
> > In fact, "squash
> > X" could just be discarded as superfluous, since it's just "pick X" +
> > "fixup" + "reword" (or we could keep squash as an abbreviation for
> > both "fixup" + "reword").
>
> IIUC, your "fixup" is
>
> git reset --soft HEAD^
> git commit --amend --no-edit
>
> i.e. discard the log message from "fixup" and use only its tree, and
> your "reword" is
>
> git commit --amend --edit
>
> so "pick X" + "fixup" + "reword" would not be quite usable as a
> replacement of our "squash X" (or your "pick X" + "squash"), I am
> afraid. You'd want the log message from "X" as well as "X^" to
> edit the replacement of X^.
Oh, good point. So, in that alternate world we'd still need a squash directive.
^ permalink raw reply
* Re: [PATCH] ls-files: add %(skipworktree) atom to format option
From: Elijah Newren @ 2023-01-14 3:00 UTC (permalink / raw)
To: ZheNing Hu
Cc: ZheNing Hu via GitGitGadget, git,
Ævar Arnfjörð Bjarmason, Junio C Hamano,
Derrick Stolee, Victoria Dye,
Nguyễn Thái Ngọc Duy
In-Reply-To: <CAOLTT8RNWJLA_UvoMA_MktkEmLSjJrx7E6Khy97cHhVFXPQD2A@mail.gmail.com>
On Fri, Jan 13, 2023 at 8:50 AM ZheNing Hu <adlternative@gmail.com> wrote:
>
> Elijah Newren <newren@gmail.com> 于2023年1月12日周四 18:00写道:
> >
> > On Wed, Jan 11, 2023 at 7:42 AM ZheNing Hu via GitGitGadget
> > <gitgitgadget@gmail.com> wrote:
> > >
[...]
> > The "and removed from working tree" portion of this sentence is
> > superfluous. (And actually makes it harder to understand, I had to
> > try to think through a bunch of cases to try to figure out why you
> > might be trying to add some extra qualifier.)
> >
>
> I just quoted the definition of SKIP_WORKTREE from
> Documentation/technical/sparse-checkout.txt:
>
> SKIP_WORKTREE: When tracked files do not match the sparse specification and
> are removed from the working tree, the file in the index is marked
> with a SKIP_WORKTREE bit.
Ah, thanks for pointing out the error. This should probably be reworded to:
SKIP_WORKTREE: When a tracked file which is unmodified does not match
the sparsity patterns, it is removed from the working tree and
the file in the index is marked with a SKIP_WORKTREE bit (to
distinguish the missing file from an unstaged deletion).
[...]
> To be honest, right now I think %(skipworktree) just refines the
> --format option's ability to read the index entry SKIP_WORKTREE
> flag bits. It is probably still worth keeping.
I'm not opposed to the idea of a special skipworktree formatting in
conjunction with ls-files' --format option, so long as it has
alternate rationale and isn't worded to suggest it supersedes `git
ls-files -t` for all sparse-checkout uses.
^ permalink raw reply
* [PATCH] ci: do not die on deprecated-declarations warning
From: Junio C Hamano @ 2023-01-14 3:47 UTC (permalink / raw)
To: git
Like a recent GitHub CI run on linux-musl [1] shows, we seem to be
getting a bunch of errors of the form:
Error: http.c:1002:9: 'CURLOPT_REDIR_PROTOCOLS' is deprecated:
since 7.85.0. Use CURLOPT_REDIR_PROTOCOLS_STR
[-Werror=deprecated-declarations]
For some of them, it may be reasonable to follow the deprecation
notice and update the code, but some symbols like the above is not.
According to the release table [2], 7.85.0 that deprecates
CURLOPT_REDIR_PROTOCOLS was released on 2022-08-31, less than a year
ago, and according to the symbols-in-versions table [3],
CURLOPT_REDIR_PROTOCOLS_STR was introduced in 7.85.0, so it will
make us incompatible with anything older than a year if we rewrote
the call as the message suggests.
Make sure that we won't break the build when -Wdeprecated-declarations
triggers.
[1] https://github.com/git/git/actions/runs/3915509922/jobs/6693756050
[2] https://curl.se/docs/releases.html
[3] https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
config.mak.dev | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/config.mak.dev b/config.mak.dev
index 981304727c..afcffa6a04 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -69,6 +69,15 @@ DEVELOPER_CFLAGS += -Wno-missing-braces
endif
endif
+# Libraries deprecate symbols while retaining them for a long time to
+# keep software working with both older and newer versions of them.
+# Getting warnings does help the developers' awareness, but we cannot
+# afford to update too aggressively. E.g. CURLOPT_REDIR_PROTOCOLS_STR
+# is only available in 7.85.0 that deprecates CURLOPT_REDIR_PROTOCOLS
+# but we cannot rewrite the uses of the latter with the former until
+# 7.85.0, which was released in August 2022, becomes ubiquitous.
+DEVELOPER_CFLAGS += -Wno-error=deprecated-declarations
+
# Old versions of clang complain about initializaing a
# struct-within-a-struct using just "{0}" rather than "{{0}}". This
# error is considered a false-positive and not worth fixing, because
--
2.39.0-198-ga38d39a4c5
^ permalink raw reply related
* Re: [PATCH] t6426: fix TODO about making test more comprehensive
From: Elijah Newren @ 2023-01-14 4:06 UTC (permalink / raw)
To: Andrei Rybak; +Cc: Elijah Newren via GitGitGadget, git
In-Reply-To: <f03094ce-e9e5-9530-7ed7-893a3f291ab0@gmail.com>
On Fri, Jan 13, 2023 at 2:09 PM Andrei Rybak <rybak.a.v@gmail.com> wrote:
>
> On 13/01/2023 05:28, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > t6426.7 (a rename/add testcase) long had a TODO/FIXME comment about
> > how the test could be improved (with some commented out sample code
> > that had a few small errors), but those improvements were blocked on
> > other changes still in progress. The necessary changes were put in
> > place years ago but the comment was forgotten. Remove and fix the
> > commented out code section and finally remove the big TODO/FIXME
> > comment.
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
>
> Thank you for taking care of this FIXME.
>
> > t6426: fix TODO about making test more comprehensive
> >
> > See
> > https://lore.kernel.org/git/CABPp-BFxK7SGs3wsOfozSw_Uvr-ynr+x8ciPV2Rmfx6Nr4si6g@mail.gmail.com/
> >
> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1462%2Fnewren%2Ft6426-fix-todo-v1
> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1462/newren/t6426-fix-todo-v1
> > Pull-Request: https://github.com/gitgitgadget/git/pull/1462
> >
> > t/t6426-merge-skip-unneeded-updates.sh | 56 ++++++++++----------------
> > 1 file changed, 22 insertions(+), 34 deletions(-)
> >
> > diff --git a/t/t6426-merge-skip-unneeded-updates.sh b/t/t6426-merge-skip-unneeded-updates.sh
> > index 2bb8e7f09bb..1fcf5d034ed 100755
> > --- a/t/t6426-merge-skip-unneeded-updates.sh
> > +++ b/t/t6426-merge-skip-unneeded-updates.sh
> > @@ -380,40 +380,28 @@ test_expect_success '2c: Modify b & add c VS rename b->c' '
> >
> > # Make sure c WAS updated
> > test-tool chmtime --get c >new-mtime &&
> > - test $(cat old-mtime) -lt $(cat new-mtime)
> > -
> > - # FIXME: rename/add conflicts are horribly broken right now;
> > - # when I get back to my patch series fixing it and
> > - # rename/rename(2to1) conflicts to bring them in line with
> > - # how add/add conflicts behave, then checks like the below
> > - # could be added. But that patch series is waiting until
> > - # the rename-directory-detection series lands, which this
> > - # is part of. And in the mean time, I do not want to further
> > - # enforce broken behavior. So for now, the main test is the
> > - # one above that err is an empty file.
> > -
> > - #git ls-files -s >index_files &&
> > - #test_line_count = 2 index_files &&
> > -
> > - #git rev-parse >actual :2:c :3:c &&
> > - #git rev-parse >expect A:b A:c &&
> > - #test_cmp expect actual &&
> > -
> > - #git cat-file -p A:b >>merged &&
> > - #git cat-file -p A:c >>merge-me &&
> > - #>empty &&
> > - #test_must_fail git merge-file \
> > - # -L "Temporary merge branch 1" \
> > - # -L "" \
> > - # -L "Temporary merge branch 2" \
> > - # merged empty merge-me &&
> > - #sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
> > -
> > - #git hash-object c >actual &&
> > - #git hash-object merged-internal >expect &&
> > - #test_cmp expect actual &&
> > -
> > - #test_path_is_missing b
> > + test $(cat old-mtime) -lt $(cat new-mtime) &&
> > +
> > + git ls-files -s >index_files &&
> > + test_line_count = 2 index_files &&
> > +
> > + git rev-parse >actual :2:c :3:c &&
> > + git rev-parse >expect A:c A:b &&
> > + test_cmp expect actual &&
> > +
> > + git cat-file -p A:b >>merge-me &&
> > + git cat-file -p A:c >>merged &&
> > + >empty &&
> > + test_must_fail git merge-file \
> > + -L "HEAD" \
> > + -L "" \
> > + -L "B^0" \
> > + merged empty merge-me &&
> > + sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
>
> It seems that this line can be dropped, because merged-internal is not
> inspected afterwards. None of the other tests in the file do similar
> calls to `sed`. Such substitutions with sed are present in
> t6422-merge-rename-corner-cases.sh and t6406-merge-attr.sh though.
Ah, good catch. There's no nested conflict, so this is totally unnecessary.
> > +
> > + test_cmp merged c &&
> > +
> > + test_path_is_missing b
>
> Function test_setup_2c() creates commits in order: commit O (create b),
> commit A (modify b, create c), and then commit B (rename b->c).
> I would have preferred if "test_path_is_missing b" check was done
> several lines higher, just before "test_line_count = 2 index_files".
> It feels more natural with this order of commits in setup to check what
> happened to file "b" first. It would also mean that all checking of
> directory contents is done in one place, before merge conflict in file
> "c" is inspected.
I'm fine with switching it. I need to remove the other superfluous line anyway.
> I see, however, that all tests in this file follow the pattern of
> checking missing files at the very end, and consistency might be
> preferable here.
After dealing with a number of really complicated conflicts (e.g. see
the mod6, rad, or rrdd testcases in t6422) where trying to go
file-by-file can just fail due to conflicts and files not being
one-to-one, I kind of got used to thinking in terms of "what's
committed", "what's in the index", "what's in the working tree". But
there's no particular reason we have to stick to that structure in
this much simpler testcase. I'm happy to move it.
> > )
> > '
> >
> >
> > base-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c
>
> Aside from unnecessary call to sed and nitpicking about order of
> assertions, the patch looks good to me.
Thanks for taking a look!
^ permalink raw reply
* Re: BUG: git grep behave oddly with alternatives
From: René Scharfe @ 2023-01-14 6:44 UTC (permalink / raw)
To: Junio C Hamano, Ævar Arnfjörð Bjarmason
Cc: Jeff King, Marco Nenciarini, git
In-Reply-To: <xmqq5yda5p4l.fsf@gitster.g>
Am 13.01.23 um 18:19 schrieb Junio C Hamano:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Thu, Jan 12 2023, Jeff King wrote:
>>
>>> So it does seem like all bets are off for what people can and should
>>> expect here. Which isn't to say we should make things worse. I mostly
>>> wondered if REG_ENHANCED might take us closer to what glibc was doing by
>>> default, but it doesn't seem like it.
>
> I thought that René's "Use enhanced only when doing BRE" was fairly
> focused, but I am very tempted to accept ...
>
>> There's a couple of ways out of this that I don't see in this thread:
>>
>> - Declare it not a problem: We have -G, -E and -P to map to BRE, ERE and
>> PCRE. One view is to say the first two must match POSIX, another is
>> tha whatever the platform thinks they should do is how they should
>> act.
>
> ... this view. The story "BRE and ERE work via what system
> libraries provide, and 'git grep' matches what system grep' does" is
> an easy to understand view.
That was my stance in my first reply as well. But 3632cfc248 (Use
compatibility regex library for OSX/Darwin, 2008-09-07) explicitly
added alternation support for BREs on macOS, and 1819ad327b (grep: fix
multibyte regex handling under macOS, 2022-08-26) removed it seemingly
by accident. And grep(1) does support them on macOS 13.1:
$ uname -rs
Darwin 22.2.0
$ which grep
/usr/bin/grep
$ grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
$ grep '\(REG_STARTEND\|NeededForASAN\)' Makefile
# Define NO_REGEX if your C library lacks regex support with REG_STARTEND
NO_REGEX = NeededForASAN
René
^ permalink raw reply
* Re: [PATCH 1/4] ls-files: add missing documentation for --resolve-undo option
From: ZheNing Hu @ 2023-01-14 8:07 UTC (permalink / raw)
To: Elijah Newren via GitGitGadget; +Cc: git, Elijah Newren
In-Reply-To: <6bd92c51550c4960ee4de272d3b19451f1e337cc.1673584914.git.gitgitgadget@gmail.com>
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> 于2023年1月13日周五 12:41写道:
>
> From: Elijah Newren <newren@gmail.com>
>
> ls-files' --resolve-undo option has existed ever since 9d9a2f4aba
> ("resolve-undo: basic tests", 2009-12-25), but was never documented.
> However, the option has been referred to in the ls-files manual itself
> ever since ce74de931d ("ls-files: introduce "--format" option",
> 2022-07-23), making its omission a bit jarring. Document this option.
>
I checked this should be the only option that git ls-files forgot to
document, thanks.
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> Documentation/git-ls-files.txt | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> index 440043cdb8e..cb071583f8b 100644
> --- a/Documentation/git-ls-files.txt
> +++ b/Documentation/git-ls-files.txt
> @@ -12,6 +12,7 @@ SYNOPSIS
> 'git ls-files' [-z] [-t] [-v] [-f]
> [-c|--cached] [-d|--deleted] [-o|--others] [-i|--ignored]
> [-s|--stage] [-u|--unmerged] [-k|--killed] [-m|--modified]
> + [--resolve-undo]
> [--directory [--no-empty-directory]] [--eol]
> [--deduplicate]
> [-x <pattern>|--exclude=<pattern>]
> @@ -77,6 +78,13 @@ OPTIONS
> to file/directory conflicts for checkout-index to
> succeed.
>
> +--resolve-undo::
> + Show files having resolve-undo information in the index
> + together with their resolve-undo information. (resolve-undo
> + information is what is used to implement "git checkout -m
> + $PATH", i.e. to recreate merge conflicts that were
> + accidentally resolved)
> +
> -z::
> \0 line termination on output and do not quote filenames.
> See OUTPUT below for more information.
> @@ -136,6 +144,7 @@ a space) at the start of each line:
> C:: modified/changed
> K:: to be killed
> ?:: other
> + U:: resolve-undo
> --
>
> -v::
> --
> gitgitgadget
>
^ permalink raw reply
* Re: [PATCH 2/4] ls-files: clarify descriptions of file selection options
From: ZheNing Hu @ 2023-01-14 8:21 UTC (permalink / raw)
To: Elijah Newren via GitGitGadget; +Cc: git, Elijah Newren
In-Reply-To: <1d1330243109d499d1c07f6518265b2e163406ef.1673584914.git.gitgitgadget@gmail.com>
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> 于2023年1月13日周五 12:41写道:
>
> From: Elijah Newren <newren@gmail.com>
>
> The previous descriptions of the file selection options were very easy
> to misunderstand. For example:
>
> * "Show cached files in the output"
> This could be interpreted as meaning "show files which have been
> modified and git-add'ed, i.e. files which have cached changes
> relative to HEAD".
>
> * "Show deleted files"
> This could be interpreted as meaning "for each `git rm $FILE` we
> ran, show me $FILE"
>
> * "Show modified files"
> This could be interpreted as meaning "show files which have been
> modified and git-add'ed" or as "show me files that differ from HEAD"
> or as "show me undeleted files different from HEAD" (given that
> --deleted is a separate option), none of which are correct.
>
> Further, it's not very clear when some options only modify and/or
> override other options, as was the case with --ignored, --directory, and
> --unmerged (I've seen folks confused by each of them on the mailing
> list, sometimes even fellow git developers.)
>
> Tweak these definitions, and the one for --killed, to try to make them
> all a bit more clear. Finally, also clarify early on that duplicate
> reports for paths are often expected (both when (a) there are multiple
> entries for the file in the index -- i.e. when there are conflicts, and
> also (b) when the user specifies options that might pick the same file
> multiple times, such as `git ls-files --cached --deleted --modified`
> when there is a file with an unstaged deletion).
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> Documentation/git-ls-files.txt | 37 ++++++++++++++++++++++------------
> 1 file changed, 24 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> index cb071583f8b..f89ab1bfc98 100644
> --- a/Documentation/git-ls-files.txt
> +++ b/Documentation/git-ls-files.txt
> @@ -29,21 +29,26 @@ This merges the file listing in the index with the actual working
> directory list, and shows different combinations of the two.
>
> One or more of the options below may be used to determine the files
> -shown:
> +shown, and each file may be printed multiple times if there are
> +multiple entries in the index or multiple statuses are applicable for
> +the relevant file selection options.
>
`--deduplicate` option can be used to remove deduped output.
> OPTIONS
> -------
> -c::
> --cached::
> - Show cached files in the output (default)
> + Show all files cached in Git's index, i.e. all tracked files.
> + (This is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo
> + options are specified.)
>
> -d::
> --deleted::
> - Show deleted files in the output
> + Show files with an unstaged deletion
>
This is a nice fix: make it clear to the user that only files in the
working tree are deleted, not in the index.
> -m::
> --modified::
> - Show modified files in the output
> + Show files with an unstaged modification (note that an unstaged
> + deletion also counts as an unstaged modification)
>
Good to mention that deleted files are also modified, otherwise no one
looking at the documentation would know that.
> -o::
> --others::
> @@ -51,11 +56,14 @@ OPTIONS
>
> -i::
> --ignored::
> - Show only ignored files in the output. When showing files in the
> - index, print only those matched by an exclude pattern. When
> - showing "other" files, show only those matched by an exclude
> - pattern. Standard ignore rules are not automatically activated,
> - therefore at least one of the `--exclude*` options is required.
> + Show only ignored files in the output. Must be used with
> + either an explicit '-c' or '-o'. When showing files in the
> + index (i.e. when used with '-c'), print only those files
> + matching an exclude pattern. When showing "other" files
> + (i.e. when used with '-o'), show only those matched by an
> + exclude pattern. Standard ignore rules are not automatically
> + activated, therefore at least one of the `--exclude*` options
> + is required.
>
> -s::
> --stage::
> @@ -64,19 +72,22 @@ OPTIONS
> --directory::
> If a whole directory is classified as "other", show just its
> name (with a trailing slash) and not its whole contents.
> + Has no effect without -o/--others.
>
> --no-empty-directory::
> Do not list empty directories. Has no effect without --directory.
>
> -u::
> --unmerged::
> - Show unmerged files in the output (forces --stage)
> + Show information about unmerged files in the output, but do
> + not show any other tracked files (forces --stage, overrides
> + --cached).
>
> -k::
> --killed::
> - Show files on the filesystem that need to be removed due
> - to file/directory conflicts for checkout-index to
> - succeed.
> + Show untracked files on the filesystem that need to be removed
> + due to file/directory conflicts for tracked files to be able to
> + be written to the filesystem.
>
> --resolve-undo::
> Show files having resolve-undo information in the index
> --
> gitgitgadget
>
^ permalink raw reply
* Re: [PATCH v6 2/2] attr: add flag `--source` to work with tree-ish
From: Karthik Nayak @ 2023-01-14 8:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <xmqq4jsu13id.fsf@gitster.g>
On Fri, Jan 13, 2023 at 11:19 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Karthik Nayak <karthik.188@gmail.com> writes:
>
> > diff --git a/attr.h b/attr.h
> > index 3fb40cced0..f4a2bedd68 100644
> > --- a/attr.h
> > +++ b/attr.h
> > @@ -1,6 +1,8 @@
> > #ifndef ATTR_H
> > #define ATTR_H
> >
> > +#include "hash.h"
>
> You only want "struct object_id" declared. Why include the whole
> file?
I see, I should have just used your patch, will add this and Ævar's
[0] suggestion and do a quick re-roll. Thanks!
[0]: https://lore.kernel.org/git/230112.86lem728ig.gmgdl@evledraar.gmail.com/
^ permalink raw reply
* Re: [PATCH v5 2/2] attr: add flag `--source` to work with tree-ish
From: Karthik Nayak @ 2023-01-14 8:26 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: git, Toon Claes
In-Reply-To: <230112.86lem728ig.gmgdl@evledraar.gmail.com>
On Thu, Jan 12, 2023 at 2:21 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
>
> On Mon, Jan 02 2023, Karthik Nayak wrote:
>
> > +static struct attr_stack *read_attr_from_blob(struct index_state *istate,
> > + const struct object_id *tree_oid,
> > + const char *path, unsigned flags)
> > +{
> > + struct object_id oid;
> > + unsigned long sz;
> > + enum object_type type;
> > + void *buf;
> > + unsigned short mode;
> > +
> > + if (!tree_oid)
> > + return NULL;
> > +
> > + if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
> > + return NULL;
> > +
> > + buf = read_object_file(&oid, &type, &sz);
>
> Here you flip-flop between istate->repo and "the_repository". I think
> you want to use repo_read_object_file(istate->repo, ...) instead.
Let me add this to v7! Thanks
^ permalink raw reply
* Re: [PATCH 3/4] ls-files: clarify descriptions of status tags for -t
From: ZheNing Hu @ 2023-01-14 8:26 UTC (permalink / raw)
To: Elijah Newren via GitGitGadget; +Cc: git, Elijah Newren
In-Reply-To: <26406a4d8797e68f0ba4fe097cf0973f60d67114.1673584914.git.gitgitgadget@gmail.com>
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> 于2023年1月13日周五 12:41写道:
>
> From: Elijah Newren <newren@gmail.com>
>
> Much like the file selection options we tweaked in the last commit, the
> status tags printed with -t had descriptions that were easy to
> misunderstand, and for many of the same reasons. Clarify them.
>
> Also, while at it, remove the "semi-deprecated" comment for "git
> ls-files -t". The -t option was marked as semi-deprecated in 5bc0e247c4
> ("Document ls-files -t as semi-obsolete.", 2010-07-28) because:
>
> "git ls-files -t" is [...] badly documented, hence we point the
> users to superior alternatives.
> The feature is marked as "semi-obsolete" but not "scheduled for removal"
> since it's a plumbing command, scripts might use it, and Git testsuite
> already uses it to test the state of the index.
>
> Marking it as obsolete because it was easily misunderstood, which I
> think was primarily due to documentation problems, is one strategy, but
> I think fixing the documentation is a better option. Especially since
> in the intervening time, "git ls-files -t" has become heavily used by
> sparse-checkout users where the same confusion just doesn't apply.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> Documentation/git-ls-files.txt | 28 +++++++++++++++-------------
> 1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> index f89ab1bfc98..3886d58d178 100644
> --- a/Documentation/git-ls-files.txt
> +++ b/Documentation/git-ls-files.txt
> @@ -137,25 +137,27 @@ OPTIONS
> with `-s` or `-u` options does not make any sense.
>
> -t::
> - This feature is semi-deprecated. For scripting purpose,
> - linkgit:git-status[1] `--porcelain` and
> + Show status tags together with filenames. Note that for
> + scripting purposes, linkgit:git-status[1] `--porcelain` and
> linkgit:git-diff-files[1] `--name-status` are almost always
> superior alternatives, and users should look at
> linkgit:git-status[1] `--short` or linkgit:git-diff[1]
> `--name-status` for more user-friendly alternatives.
> +
> --
> -This option identifies the file status with the following tags (followed by
> -a space) at the start of each line:
> -
> - H:: cached
> - S:: skip-worktree
> - M:: unmerged
> - R:: removed/deleted
> - C:: modified/changed
> - K:: to be killed
> - ?:: other
> - U:: resolve-undo
> +This option provides a reason for showing each filename, in the form
> +of a status tag (which is followed by a space and then the filename).
> +The status tags are all single characters from the following list:
> +
> + H:: tracked file that is not either unmerged or skip-worktree
> + S:: tracked file that is skip-worktree
> + M:: tracked file that is unmerged
> + R:: tracked file with unstaged removal/deletion
> + C:: tracked file with unstaged modification/change
> + K:: untracked paths which are part of file/directory conflicts
> + which prevent checking out tracked files
> + ?:: untracked file
> + U:: file with resolve-undo information
> --
>
Good to see these tags describe are changed, especially "K" (reader
don't know what is "to be killed")
Maybe we should mention which option will output these tags?
e.g. default -> "H"/"S" ,`--other` -> "?", `--modified` -> "C",
`--killed` -> "K"...
> -v::
> --
> gitgitgadget
>
^ permalink raw reply
* [PATCH v7 0/2] check-attr: add support to work with tree-ish
From: Karthik Nayak @ 2023-01-14 8:30 UTC (permalink / raw)
To: git; +Cc: phillip.wood, sunshine, Karthik Nayak
In-Reply-To: <https://lore.kernel.org/git/cover.1673521102.git.karthik.188@gmail.com/>
v1: https://lore.kernel.org/git/20221206103736.53909-1-karthik.188@gmail.com/
v2: https://lore.kernel.org/git/CAOLa=ZSsFGBw3ta1jWN8cmUch2ca=zTEjp1xMA6Linafx9W53g@mail.gmail.com/T/#t
v3: https://lore.kernel.org/git/20221216093552.3171319-1-karthik.188@gmail.com/
v4: https://lore.kernel.org/git/cover.1671630304.git.karthik.188@gmail.com
v5: https://lore.kernel.org/git/cover.1671793109.git.karthik.188@gmail.com/
v6: https://lore.kernel.org/git/cover.1673521102.git.karthik.188@gmail.com/
Given a pathname, git-check-attr(1) will list the attributes which apply to that
pathname by reading all relevant gitattributes files. Currently there is no way
to specify a tree-ish to read the gitattributes from.
This is specifically useful in bare repositories wherein the gitattributes are
only present in the git working tree but not available directly on the
filesystem.
This series aims to add a new flag `--source` to git-check-attr(1) which
allows us to read gitattributes from the specified tree-ish.
Changes since v6:
- s/read_object_file/repo_read_object_file to make it more consistent
- In attr.h define 'struct object_id' instead of including 'hash.h'
Range-diff against v5:
1: 6224754179 = 1: 6224754179 t0003: move setup for `--all` into new block
2: 57f5957127 ! 2: 0ca8b24589 attr: add flag `--source` to work with tree-ish
@@ attr.c: static struct attr_stack *read_attr_from_file(const char *path, unsigned
+ if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
+ return NULL;
+
-+ buf = read_object_file(&oid, &type, &sz);
++ buf = repo_read_object_file(istate->repo, &oid, &type, &sz);
+ if (!buf || type != OBJ_BLOB) {
+ free(buf);
+ return NULL;
@@ attr.c: void git_check_attr(struct index_state *istate,
## attr.h ##
@@
- #ifndef ATTR_H
- #define ATTR_H
+ */
+
+ struct index_state;
++struct object_id;
-+#include "hash.h"
-+
/**
- * gitattributes mechanism gives a uniform way to associate various attributes
- * to set of paths.
+ * An attribute is an opaque object that is identified by its name. Pass the
@@ attr.h: void attr_check_free(struct attr_check *check);
const char *git_attr_name(const struct git_attr *);
Karthik Nayak (2):
t0003: move setup for `--all` into new block
attr: add flag `--source` to work with tree-ish
Documentation/git-check-attr.txt | 9 ++-
archive.c | 2 +-
attr.c | 97 +++++++++++++++++++++++---------
attr.h | 6 +-
builtin/check-attr.c | 35 +++++++-----
builtin/pack-objects.c | 2 +-
convert.c | 2 +-
ll-merge.c | 4 +-
pathspec.c | 2 +-
t/t0003-attributes.sh | 48 +++++++++++++++-
userdiff.c | 2 +-
ws.c | 2 +-
12 files changed, 156 insertions(+), 55 deletions(-)
--
2.39.0
^ permalink raw reply
* [PATCH v7 1/2] t0003: move setup for `--all` into new block
From: Karthik Nayak @ 2023-01-14 8:30 UTC (permalink / raw)
To: git; +Cc: phillip.wood, sunshine, Karthik Nayak, toon
In-Reply-To: <cover.1673684790.git.karthik.188@gmail.com>
There is some setup code which is used by multiple tests being setup in
`attribute test: --all option`. This means when we run "sh
./t0003-attributes.sh --run=setup,<num>" there is a chance of failing
since we missed this setup block.
So to ensure that setups are independent of test logic, move this to a
new setup block.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Co-authored-by: toon@iotcl.com
---
t/t0003-attributes.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index f7ee2f2ff0..b3aabb8aa3 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -203,9 +203,12 @@ test_expect_success 'attribute test: read paths from stdin' '
test_cmp expect actual
'
-test_expect_success 'attribute test: --all option' '
+test_expect_success 'setup --all option' '
grep -v unspecified <expect-all | sort >specified-all &&
- sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
+ sed -e "s/:.*//" <expect-all | uniq >stdin-all
+'
+
+test_expect_success 'attribute test: --all option' '
git check-attr --stdin --all <stdin-all >tmp &&
sort tmp >actual &&
test_cmp specified-all actual
--
2.39.0
^ permalink raw reply related
* [PATCH v7 2/2] attr: add flag `--source` to work with tree-ish
From: Karthik Nayak @ 2023-01-14 8:30 UTC (permalink / raw)
To: git; +Cc: phillip.wood, sunshine, Karthik Nayak, Toon Claes
In-Reply-To: <cover.1673684790.git.karthik.188@gmail.com>
The contents of the .gitattributes files may evolve over time, but "git
check-attr" always checks attributes against them in the working tree
and/or in the index. It may be beneficial to optionally allow the users
to check attributes taken from a commit other than HEAD against paths.
Add a new flag `--source` which will allow users to check the
attributes against a commit (actually any tree-ish would do). When the
user uses this flag, we go through the stack of .gitattributes files but
instead of checking the current working tree and/or in the index, we
check the blobs from the provided tree-ish object. This allows the
command to also be used in bare repositories.
Since we use a tree-ish object, the user can pass "--source
HEAD:subdirectory" and all the attributes will be looked up as if
subdirectory was the root directory of the repository.
We cannot simply use the `<rev>:<path>` syntax without the `--source`
flag, similar to how it is used in `git show` because any non-flag
parameter before `--` is treated as an attribute and any parameter after
`--` is treated as a pathname.
The change involves creating a new function `read_attr_from_blob`, which
given the path reads the blob for the path against the provided source and
parses the attributes line by line. This function is plugged into
`read_attr()` function wherein we go through the stack of attributes
files.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Toon Claes <toon@iotcl.com>
Co-authored-by: toon@iotcl.com
---
Documentation/git-check-attr.txt | 9 ++-
archive.c | 2 +-
attr.c | 97 +++++++++++++++++++++++---------
attr.h | 6 +-
builtin/check-attr.c | 35 +++++++-----
builtin/pack-objects.c | 2 +-
convert.c | 2 +-
ll-merge.c | 4 +-
pathspec.c | 2 +-
t/t0003-attributes.sh | 41 +++++++++++++-
userdiff.c | 2 +-
ws.c | 2 +-
12 files changed, 151 insertions(+), 53 deletions(-)
diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt
index 84f41a8e82..6e4f3aaf34 100644
--- a/Documentation/git-check-attr.txt
+++ b/Documentation/git-check-attr.txt
@@ -9,8 +9,8 @@ git-check-attr - Display gitattributes information
SYNOPSIS
--------
[verse]
-'git check-attr' [-a | --all | <attr>...] [--] <pathname>...
-'git check-attr' --stdin [-z] [-a | --all | <attr>...]
+'git check-attr' [--source <tree-ish>] [-a | --all | <attr>...] [--] <pathname>...
+'git check-attr' --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>...]
DESCRIPTION
-----------
@@ -36,6 +36,11 @@ OPTIONS
If `--stdin` is also given, input paths are separated
with a NUL character instead of a linefeed character.
+--source=<tree-ish>::
+ Check attributes against the specified tree-ish. It is common to
+ specify the source tree by naming a commit, branch or tag associated
+ with it.
+
\--::
Interpret all preceding arguments as attributes and all following
arguments as path names.
diff --git a/archive.c b/archive.c
index 941495f5d7..81ff76fce9 100644
--- a/archive.c
+++ b/archive.c
@@ -120,7 +120,7 @@ static const struct attr_check *get_archive_attrs(struct index_state *istate,
static struct attr_check *check;
if (!check)
check = attr_check_initl("export-ignore", "export-subst", NULL);
- git_check_attr(istate, path, check);
+ git_check_attr(istate, NULL, path, check);
return check;
}
diff --git a/attr.c b/attr.c
index 42ad6de8c7..9a1dcac470 100644
--- a/attr.c
+++ b/attr.c
@@ -13,6 +13,8 @@
#include "dir.h"
#include "utf8.h"
#include "quote.h"
+#include "revision.h"
+#include "object-store.h"
#include "thread-utils.h"
const char git_attr__true[] = "(builtin)true";
@@ -729,14 +731,62 @@ static struct attr_stack *read_attr_from_file(const char *path, unsigned flags)
return res;
}
-static struct attr_stack *read_attr_from_index(struct index_state *istate,
- const char *path,
- unsigned flags)
+static struct attr_stack *read_attr_from_buf(char *buf, const char *path,
+ unsigned flags)
{
struct attr_stack *res;
- char *buf, *sp;
+ char *sp;
int lineno = 0;
+ if (!buf)
+ return NULL;
+
+ CALLOC_ARRAY(res, 1);
+ for (sp = buf; *sp;) {
+ char *ep;
+ int more;
+
+ ep = strchrnul(sp, '\n');
+ more = (*ep == '\n');
+ *ep = '\0';
+ handle_attr_line(res, sp, path, ++lineno, flags);
+ sp = ep + more;
+ }
+ free(buf);
+
+ return res;
+}
+
+static struct attr_stack *read_attr_from_blob(struct index_state *istate,
+ const struct object_id *tree_oid,
+ const char *path, unsigned flags)
+{
+ struct object_id oid;
+ unsigned long sz;
+ enum object_type type;
+ void *buf;
+ unsigned short mode;
+
+ if (!tree_oid)
+ return NULL;
+
+ if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
+ return NULL;
+
+ buf = repo_read_object_file(istate->repo, &oid, &type, &sz);
+ if (!buf || type != OBJ_BLOB) {
+ free(buf);
+ return NULL;
+ }
+
+ return read_attr_from_buf(buf, path, flags);
+}
+
+static struct attr_stack *read_attr_from_index(struct index_state *istate,
+ const char *path, unsigned flags)
+{
+ char *buf;
+
if (!istate)
return NULL;
@@ -758,28 +808,19 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
if (!buf)
return NULL;
- CALLOC_ARRAY(res, 1);
- for (sp = buf; *sp; ) {
- char *ep;
- int more;
-
- ep = strchrnul(sp, '\n');
- more = (*ep == '\n');
- *ep = '\0';
- handle_attr_line(res, sp, path, ++lineno, flags);
- sp = ep + more;
- }
- free(buf);
- return res;
+ return read_attr_from_buf(buf, path, flags);
}
static struct attr_stack *read_attr(struct index_state *istate,
+ const struct object_id *tree_oid,
const char *path, unsigned flags)
{
struct attr_stack *res = NULL;
if (direction == GIT_ATTR_INDEX) {
res = read_attr_from_index(istate, path, flags);
+ } else if (tree_oid) {
+ res = read_attr_from_blob(istate, tree_oid, path, flags);
} else if (!is_bare_repository()) {
if (direction == GIT_ATTR_CHECKOUT) {
res = read_attr_from_index(istate, path, flags);
@@ -839,6 +880,7 @@ static void push_stack(struct attr_stack **attr_stack_p,
}
static void bootstrap_attr_stack(struct index_state *istate,
+ const struct object_id *tree_oid,
struct attr_stack **stack)
{
struct attr_stack *e;
@@ -864,7 +906,7 @@ static void bootstrap_attr_stack(struct index_state *istate,
}
/* root directory */
- e = read_attr(istate, GITATTRIBUTES_FILE, flags | READ_ATTR_NOFOLLOW);
+ e = read_attr(istate, tree_oid, GITATTRIBUTES_FILE, flags | READ_ATTR_NOFOLLOW);
push_stack(stack, e, xstrdup(""), 0);
/* info frame */
@@ -878,6 +920,7 @@ static void bootstrap_attr_stack(struct index_state *istate,
}
static void prepare_attr_stack(struct index_state *istate,
+ const struct object_id *tree_oid,
const char *path, int dirlen,
struct attr_stack **stack)
{
@@ -899,7 +942,7 @@ static void prepare_attr_stack(struct index_state *istate,
* .gitattributes in deeper directories to shallower ones,
* and finally use the built-in set as the default.
*/
- bootstrap_attr_stack(istate, stack);
+ bootstrap_attr_stack(istate, tree_oid, stack);
/*
* Pop the "info" one that is always at the top of the stack.
@@ -954,7 +997,7 @@ static void prepare_attr_stack(struct index_state *istate,
strbuf_add(&pathbuf, path + pathbuf.len, (len - pathbuf.len));
strbuf_addf(&pathbuf, "/%s", GITATTRIBUTES_FILE);
- next = read_attr(istate, pathbuf.buf, READ_ATTR_NOFOLLOW);
+ next = read_attr(istate, tree_oid, pathbuf.buf, READ_ATTR_NOFOLLOW);
/* reset the pathbuf to not include "/.gitattributes" */
strbuf_setlen(&pathbuf, len);
@@ -1074,8 +1117,8 @@ static void determine_macros(struct all_attrs_item *all_attrs,
* Otherwise all attributes are collected.
*/
static void collect_some_attrs(struct index_state *istate,
- const char *path,
- struct attr_check *check)
+ const struct object_id *tree_oid,
+ const char *path, struct attr_check *check)
{
int pathlen, rem, dirlen;
const char *cp, *last_slash = NULL;
@@ -1094,7 +1137,7 @@ static void collect_some_attrs(struct index_state *istate,
dirlen = 0;
}
- prepare_attr_stack(istate, path, dirlen, &check->stack);
+ prepare_attr_stack(istate, tree_oid, path, dirlen, &check->stack);
all_attrs_init(&g_attr_hashmap, check);
determine_macros(check->all_attrs, check->stack);
@@ -1103,12 +1146,12 @@ static void collect_some_attrs(struct index_state *istate,
}
void git_check_attr(struct index_state *istate,
- const char *path,
+ const struct object_id *tree_oid, const char *path,
struct attr_check *check)
{
int i;
- collect_some_attrs(istate, path, check);
+ collect_some_attrs(istate, tree_oid, path, check);
for (i = 0; i < check->nr; i++) {
size_t n = check->items[i].attr->attr_nr;
@@ -1119,13 +1162,13 @@ void git_check_attr(struct index_state *istate,
}
}
-void git_all_attrs(struct index_state *istate,
+void git_all_attrs(struct index_state *istate, const struct object_id *tree_oid,
const char *path, struct attr_check *check)
{
int i;
attr_check_reset(check);
- collect_some_attrs(istate, path, check);
+ collect_some_attrs(istate, tree_oid, path, check);
for (i = 0; i < check->all_attrs_nr; i++) {
const char *name = check->all_attrs[i].attr->name;
diff --git a/attr.h b/attr.h
index 3fb40cced0..fca6c30430 100644
--- a/attr.h
+++ b/attr.h
@@ -108,6 +108,7 @@
*/
struct index_state;
+struct object_id;
/**
* An attribute is an opaque object that is identified by its name. Pass the
@@ -190,13 +191,14 @@ void attr_check_free(struct attr_check *check);
const char *git_attr_name(const struct git_attr *);
void git_check_attr(struct index_state *istate,
- const char *path, struct attr_check *check);
+ const struct object_id *tree_oid, const char *path,
+ struct attr_check *check);
/*
* Retrieve all attributes that apply to the specified path.
* check holds the attributes and their values.
*/
-void git_all_attrs(struct index_state *istate,
+void git_all_attrs(struct index_state *istate, const struct object_id *tree_oid,
const char *path, struct attr_check *check);
enum git_attr_direction {
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 0fef10eb6b..d7a40e674c 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -9,9 +9,10 @@
static int all_attrs;
static int cached_attrs;
static int stdin_paths;
+static char *source;
static const char * const check_attr_usage[] = {
-N_("git check-attr [-a | --all | <attr>...] [--] <pathname>..."),
-N_("git check-attr --stdin [-z] [-a | --all | <attr>...]"),
+N_("git check-attr [--source <tree-ish>] [-a | --all | <attr>...] [--] <pathname>..."),
+N_("git check-attr --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>...]"),
NULL
};
@@ -23,6 +24,7 @@ static const struct option check_attr_options[] = {
OPT_BOOL(0 , "stdin", &stdin_paths, N_("read file names from stdin")),
OPT_BOOL('z', NULL, &nul_term_line,
N_("terminate input and output records by a NUL character")),
+ OPT_STRING(0, "source", &source, N_("<tree-ish>"), N_("which tree-ish to check attributes at")),
OPT_END()
};
@@ -55,27 +57,26 @@ static void output_attr(struct attr_check *check, const char *file)
}
}
-static void check_attr(const char *prefix,
- struct attr_check *check,
- int collect_all,
+static void check_attr(const char *prefix, struct attr_check *check,
+ const struct object_id *tree_oid, int collect_all,
const char *file)
+
{
char *full_path =
prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
if (collect_all) {
- git_all_attrs(&the_index, full_path, check);
+ git_all_attrs(&the_index, tree_oid, full_path, check);
} else {
- git_check_attr(&the_index, full_path, check);
+ git_check_attr(&the_index, tree_oid, full_path, check);
}
output_attr(check, file);
free(full_path);
}
-static void check_attr_stdin_paths(const char *prefix,
- struct attr_check *check,
- int collect_all)
+static void check_attr_stdin_paths(const char *prefix, struct attr_check *check,
+ const struct object_id *tree_oid, int collect_all)
{
struct strbuf buf = STRBUF_INIT;
struct strbuf unquoted = STRBUF_INIT;
@@ -89,7 +90,7 @@ static void check_attr_stdin_paths(const char *prefix,
die("line is badly quoted");
strbuf_swap(&buf, &unquoted);
}
- check_attr(prefix, check, collect_all, buf.buf);
+ check_attr(prefix, check, tree_oid, collect_all, buf.buf);
maybe_flush_or_die(stdout, "attribute to stdout");
}
strbuf_release(&buf);
@@ -105,6 +106,8 @@ static NORETURN void error_with_usage(const char *msg)
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
struct attr_check *check;
+ struct object_id *tree_oid = NULL;
+ struct object_id initialized_oid;
int cnt, i, doubledash, filei;
if (!is_bare_repository())
@@ -176,11 +179,17 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
}
}
+ if (source) {
+ if (repo_get_oid_tree(the_repository, source, &initialized_oid))
+ die("%s: not a valid tree-ish source", source);
+ tree_oid = &initialized_oid;
+ }
+
if (stdin_paths)
- check_attr_stdin_paths(prefix, check, all_attrs);
+ check_attr_stdin_paths(prefix, check, tree_oid, all_attrs);
else {
for (i = filei; i < argc; i++)
- check_attr(prefix, check, all_attrs, argv[i]);
+ check_attr(prefix, check, tree_oid, all_attrs, argv[i]);
maybe_flush_or_die(stdout, "attribute to stdout");
}
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 573d0b20b7..89535cfa6a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1318,7 +1318,7 @@ static int no_try_delta(const char *path)
if (!check)
check = attr_check_initl("delta", NULL);
- git_check_attr(the_repository->index, path, check);
+ git_check_attr(the_repository->index, NULL, path, check);
if (ATTR_FALSE(check->items[0].value))
return 1;
return 0;
diff --git a/convert.c b/convert.c
index 9b67649032..a54d1690c0 100644
--- a/convert.c
+++ b/convert.c
@@ -1308,7 +1308,7 @@ void convert_attrs(struct index_state *istate,
git_config(read_convert_config, NULL);
}
- git_check_attr(istate, path, check);
+ git_check_attr(istate, NULL, path, check);
ccheck = check->items;
ca->crlf_action = git_path_check_crlf(ccheck + 4);
if (ca->crlf_action == CRLF_UNDEFINED)
diff --git a/ll-merge.c b/ll-merge.c
index 22a603e8af..130d26501c 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -391,7 +391,7 @@ enum ll_merge_result ll_merge(mmbuffer_t *result_buf,
normalize_file(theirs, path, istate);
}
- git_check_attr(istate, path, check);
+ git_check_attr(istate, NULL, path, check);
ll_driver_name = check->items[0].value;
if (check->items[1].value) {
marker_size = atoi(check->items[1].value);
@@ -419,7 +419,7 @@ int ll_merge_marker_size(struct index_state *istate, const char *path)
if (!check)
check = attr_check_initl("conflict-marker-size", NULL);
- git_check_attr(istate, path, check);
+ git_check_attr(istate, NULL, path, check);
if (check->items[0].value) {
marker_size = atoi(check->items[0].value);
if (marker_size <= 0)
diff --git a/pathspec.c b/pathspec.c
index 46e77a85fe..48dec2c709 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -732,7 +732,7 @@ int match_pathspec_attrs(struct index_state *istate,
if (name[namelen])
name = to_free = xmemdupz(name, namelen);
- git_check_attr(istate, name, item->attr_check);
+ git_check_attr(istate, NULL, name, item->attr_check);
free(to_free);
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index b3aabb8aa3..6ae30ab080 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -25,7 +25,15 @@ attr_check_quote () {
git check-attr test -- "$path" >actual &&
echo "\"$quoted_path\": test: $expect" >expect &&
test_cmp expect actual
+}
+
+attr_check_source () {
+ path="$1" expect="$2" source="$3" git_opts="$4" &&
+ git $git_opts check-attr --source $source test -- "$path" >actual 2>err &&
+ echo "$path: test: $expect" >expect &&
+ test_cmp expect actual &&
+ test_must_be_empty err
}
test_expect_success 'open-quoted pathname' '
@@ -33,7 +41,6 @@ test_expect_success 'open-quoted pathname' '
attr_check a unspecified
'
-
test_expect_success 'setup' '
mkdir -p a/b/d a/c b &&
(
@@ -80,12 +87,23 @@ test_expect_success 'setup' '
EOF
'
+test_expect_success 'setup branches' '
+ mkdir -p foo/bar &&
+ test_commit --printf "add .gitattributes" foo/bar/.gitattributes \
+ "f test=f\na/i test=n\n" tag-1 &&
+ test_commit --printf "add .gitattributes" foo/bar/.gitattributes \
+ "g test=g\na/i test=m\n" tag-2 &&
+ rm foo/bar/.gitattributes
+'
+
test_expect_success 'command line checks' '
test_must_fail git check-attr &&
test_must_fail git check-attr -- &&
test_must_fail git check-attr test &&
test_must_fail git check-attr test -- &&
test_must_fail git check-attr -- f &&
+ test_must_fail git check-attr --source &&
+ test_must_fail git check-attr --source not-a-valid-ref &&
echo "f" | test_must_fail git check-attr --stdin &&
echo "f" | test_must_fail git check-attr --stdin -- f &&
echo "f" | test_must_fail git check-attr --stdin test -- f &&
@@ -287,6 +305,15 @@ test_expect_success 'using --git-dir and --work-tree' '
)
'
+test_expect_success 'using --source' '
+ attr_check_source foo/bar/f f tag-1 &&
+ attr_check_source foo/bar/a/i n tag-1 &&
+ attr_check_source foo/bar/f unspecified tag-2 &&
+ attr_check_source foo/bar/a/i m tag-2 &&
+ attr_check_source foo/bar/g g tag-2 &&
+ attr_check_source foo/bar/g unspecified tag-1
+'
+
test_expect_success 'setup bare' '
git clone --template= --bare . bare.git
'
@@ -306,6 +333,18 @@ test_expect_success 'bare repository: check that .gitattribute is ignored' '
)
'
+test_expect_success 'bare repository: with --source' '
+ (
+ cd bare.git &&
+ attr_check_source foo/bar/f f tag-1 &&
+ attr_check_source foo/bar/a/i n tag-1 &&
+ attr_check_source foo/bar/f unspecified tag-2 &&
+ attr_check_source foo/bar/a/i m tag-2 &&
+ attr_check_source foo/bar/g g tag-2 &&
+ attr_check_source foo/bar/g unspecified tag-1
+ )
+'
+
test_expect_success 'bare repository: check that --cached honors index' '
(
cd bare.git &&
diff --git a/userdiff.c b/userdiff.c
index 151d9a5278..b66f090a0b 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -412,7 +412,7 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
check = attr_check_initl("diff", NULL);
if (!path)
return NULL;
- git_check_attr(istate, path, check);
+ git_check_attr(istate, NULL, path, check);
if (ATTR_TRUE(check->items[0].value))
return &driver_true;
diff --git a/ws.c b/ws.c
index 6e69877f25..eadbbe5667 100644
--- a/ws.c
+++ b/ws.c
@@ -78,7 +78,7 @@ unsigned whitespace_rule(struct index_state *istate, const char *pathname)
if (!attr_whitespace_rule)
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
- git_check_attr(istate, pathname, attr_whitespace_rule);
+ git_check_attr(istate, NULL, pathname, attr_whitespace_rule);
value = attr_whitespace_rule->items[0].value;
if (ATTR_TRUE(value)) {
/* true (whitespace) */
--
2.39.0
^ permalink raw reply related
* Re: BUG: git grep behave oddly with alternatives
From: René Scharfe @ 2023-01-14 8:31 UTC (permalink / raw)
To: Junio C Hamano, Ævar Arnfjörð Bjarmason
Cc: Jeff King, Marco Nenciarini, git, Diomidis Spinellis
In-Reply-To: <0e25e6b0-2eb8-40ee-7999-f2863a545a15@web.de>
Am 14.01.23 um 07:44 schrieb René Scharfe:
> Am 13.01.23 um 18:19 schrieb Junio C Hamano:
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>>> On Thu, Jan 12 2023, Jeff King wrote:
>>>
>>>> So it does seem like all bets are off for what people can and should
>>>> expect here. Which isn't to say we should make things worse. I mostly
>>>> wondered if REG_ENHANCED might take us closer to what glibc was doing by
>>>> default, but it doesn't seem like it.
>>
>> I thought that René's "Use enhanced only when doing BRE" was fairly
>> focused, but I am very tempted to accept ...
>>
>>> There's a couple of ways out of this that I don't see in this thread:
>>>
>>> - Declare it not a problem: We have -G, -E and -P to map to BRE, ERE and
>>> PCRE. One view is to say the first two must match POSIX, another is
>>> tha whatever the platform thinks they should do is how they should
>>> act.
>>
>> ... this view. The story "BRE and ERE work via what system
>> libraries provide, and 'git grep' matches what system grep' does" is
>> an easy to understand view.
>
> That was my stance in my first reply as well. But 3632cfc248 (Use
> compatibility regex library for OSX/Darwin, 2008-09-07) explicitly
> added alternation support for BREs on macOS, and 1819ad327b (grep: fix
> multibyte regex handling under macOS, 2022-08-26) removed it seemingly
> by accident. And grep(1) does support them on macOS 13.1:
>
> $ uname -rs
> Darwin 22.2.0
> $ which grep
> /usr/bin/grep
> $ grep --version
> grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
> $ grep '\(REG_STARTEND\|NeededForASAN\)' Makefile
> # Define NO_REGEX if your C library lacks regex support with REG_STARTEND
> NO_REGEX = NeededForASAN
And I neglected to copy the author of 1819ad327b until now. :-|
@Diomidis: Here's a link to the start of this thread:
https://lore.kernel.org/git/f82ae28a-fb56-8d1f-96c8-550b61439d3a@enterprisedb.com/
René
^ permalink raw reply
* What's cooking in git.git (Jan 2023, #04; Sat, 14)
From: Junio C Hamano @ 2023-01-14 8:36 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. A topic without enough support may be
discarded after a long period of no activity.
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/
--------------------------------------------------
[New Topics]
* ab/cache-api-cleanup (2023-01-13) 5 commits
- cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()
- read-cache.c: refactor set_new_index_sparsity() for subsequent commit
- sparse-index API: BUG() out on NULL ensure_full_index()
- sparse-index.c: expand_to_path() can assume non-NULL "istate"
- builtin/difftool.c: { 0 }-initialize rather than using memset()
Code clean-up to tighten the use of in-core index in the API.
Will merge to 'next'.
source: <cover-v2-0.6-00000000000-20230112T124842Z-avarab@gmail.com>
* ab/test-env-helper (2023-01-13) 1 commit
- env-helper: move this built-in to to "test-tool env-helper"
Remove "git env--helper" and demote it to a test-tool subcommand.
Will merge to 'next'.
source: <patch-1.1-e662c570f1d-20230112T155226Z-avarab@gmail.com>
* ar/bisect-doc-update (2023-01-13) 2 commits
- git-bisect-lk2009: update nist report link
- git-bisect-lk2009: update java code conventions link
Doc update.
Will merge to 'next'.
source: <20230110093251.193552-1-rybak.a.v@gmail.com>
* ar/test-cleanup (2023-01-13) 3 commits
- t7527: use test_when_finished in 'case insensitive+preserving'
- t6422: drop commented out code
- t6003: uncomment test '--max-age=c3, --topo-order'
Test clean-up.
Will merge to 'next'.
source: <20230111233242.16870-1-rybak.a.v@gmail.com>
* en/ls-files-doc-update (2023-01-13) 4 commits
- ls-files: guide folks to --exclude-standard over other --exclude* options
- ls-files: clarify descriptions of status tags for -t
- ls-files: clarify descriptions of file selection options
- ls-files: add missing documentation for --resolve-undo option
Doc update to ls-files.
Needs review.
source: <pull.1463.git.1673584914.gitgitgadget@gmail.com>
* en/t6426-todo-cleanup (2023-01-13) 1 commit
- t6426: fix TODO about making test more comprehensive
Test clean-up.
Expecting a reroll.
cf. <CABPp-BE8O0beOS3=Y5Sh23KMRJGsOqmdHWD=ide4_=Zn5bWSPg@mail.gmail.com>
source: <pull.1462.git.1673584084761.gitgitgadget@gmail.com>
* jc/doc-diff-patch.txt (2023-01-13) 1 commit
- docs: link generating patch sections
Doc update.
Will merge to 'next'.
source: <pull.1392.v2.git.git.1673626524221.gitgitgadget@gmail.com>
* jk/interop-error (2023-01-13) 1 commit
- t/interop: report which vanilla git command failed
Test helper improvement.
Will merge to 'next'.
source: <Y8A3yGeJl0TCDNqe@coredump.intra.peff.net>
* pw/rebase-exec-cleanup (2023-01-13) 1 commit
- rebase: cleanup "--exec" option handling
Code clean-up.
Will merge to 'next'.
source: <pull.1461.git.1673542201452.gitgitgadget@gmail.com>
* sk/merge-filtering-strategies-micro-optim (2023-01-13) 1 commit
- merge: break out of all_strategy loop when strategy is found
Micro optimization.
Will merge to 'next'.
source: <pull.1429.v2.git.git.1673285669004.gitgitgadget@gmail.com>
* yo/doc-use-more-switch-c (2023-01-13) 1 commit
- doc: add "git switch -c" as another option on detached HEAD
Doc update.
Will merge to 'next'.
source: <pull.1422.v2.git.git.1673261237449.gitgitgadget@gmail.com>
* zh/scalar-progress (2023-01-13) 2 commits
- SQUASH???
- scalar: show progress if stderr refers to a terminal
"scalar" learned to give progress bar.
Will merge to 'next' after squashing the fixlet in?
source: <pull.1441.v3.git.1673442860379.gitgitgadget@gmail.com>
* ab/bisect-cleanup (2023-01-13) 6 commits
- bisect: no longer try to clean up left-over `.git/head-name` files
- bisect: remove Cogito-related code
- bisect run: fix the error message
- bisect: verify that a bogus option won't try to start a bisection
- bisect--helper: make the order consistently `argc, argv`
- bisect--helper: simplify exit code computation
Code clean-up.
Will merge to 'next'.
source: <cover-v2-0.6-00000000000-20230112T151651Z-avarab@gmail.com>
* ms/send-email-feed-header-to-validate-hook (2023-01-13) 2 commits
- send-email: expose header information to git-send-email's sendemail-validate hook
- send-email: refactor header generation functions
"git send-email" learned to give the e-mail headers to the validate
hook by passing an extra argument from the command line.
source: <20230110211452.2568535-1-michael.strawbridge@amd.com>
* tl/ls-tree-code-clean-up (2023-01-13) 6 commits
- t3104: remove shift code in 'test_ls_tree_format'
- ls-tree: cleanup the redundant SPACE
- ls-tree: make "line_termination" less generic
- ls-tree: fold "show_tree_data" into "cb" struct
- ls-tree: use a "struct options"
- ls-tree: don't use "show_tree_data" for "fast" callbacks
Code clean-up.
Will merge to 'next'.
source: <20230112091135.20050-1-tenglong.tl@alibaba-inc.com>
* yc/doc-fetch-fix (2023-01-13) 1 commit
- doc: fix non-existent config name
Doc fix.
Will merge to 'next'.
source: <CAEg0tHSZi22RUBREJB=Cfy6O72cicv9FTkgo_Z=gvGRdPK1acw@mail.gmail.com>
* jc/ci-deprecated-declarations-are-not-fatal (2023-01-13) 1 commit
- ci: do not die on deprecated-declarations warning
CI build fix for overzealous -Werror.
Will merge to 'next'?
source: <xmqqv8l9n5fj.fsf@gitster.g>
--------------------------------------------------
[Stalled]
* tl/notes--blankline (2022-11-09) 5 commits
- notes.c: introduce "--no-blank-line" option
- notes.c: provide tips when target and append note are both empty
- notes.c: drop unreachable code in 'append_edit()'
- notes.c: cleanup for "designated init" and "char ptr init"
- notes.c: cleanup 'strbuf_grow' call in 'append_edit'
'git notes append' was taught '--[no-]blank-line' to conditionally
add a LF between a new and existing note.
Expecting a reroll.
cf. <CAPig+cRcezSp4Rqt1Y9bD-FT6+7b0g9qHfbGRx65AOnw2FQXKg@mail.gmail.com>
source: <cover.1667980450.git.dyroneteng@gmail.com>
* po/pretty-hard-trunc (2022-11-13) 1 commit
- pretty-formats: add hard truncation, without ellipsis, options
Add a new pretty format which truncates without ellipsis.
Expecting a reroll.
cf. <093e1dca-b9d4-f1f2-0845-ad6711622cf5@iee.email>
source: <20221112143616.1429-1-philipoakley@iee.email>
* mc/switch-advice (2022-11-09) 1 commit
- po: use `switch` over `checkout` in error message
Use 'switch' instead of 'checkout' in an error message.
Waiting for review response.
source: <pull.1308.git.git.1668018620148.gitgitgadget@gmail.com>
* js/range-diff-mbox (2022-11-23) 1 commit
- range-diff: support reading mbox files
'git range-diff' gained support for reading either side from an .mbox
file instead of a revision range.
Waiting for review response.
cf. <xmqqr0xupmnf.fsf@gitster.g>
source: <pull.1420.v3.git.1669108102092.gitgitgadget@gmail.com>
* ab/tag-object-type-errors (2022-11-22) 5 commits
- tag: don't emit potentially incorrect "object is a X, not a Y"
- tag: don't misreport type of tagged objects in errors
- object tests: add test for unexpected objects in tags
- object-file.c: free the "t.tag" in check_tag()
- Merge branch 'jk/parse-object-type-mismatch' into ab/tag-object-type-errors
Hardening checks around mismatched object types when one of those
objects is a tag.
Expecting a reroll.
cf. <xmqqzgb5jz5c.fsf@gitster.g>
cf. <xmqqsfgxjugi.fsf@gitster.g>
source: <cover-0.4-00000000000-20221118T113442Z-avarab@gmail.com>
* ab/config-multi-and-nonbool (2022-11-27) 9 commits
- for-each-repo: with bad config, don't conflate <path> and <cmd>
- config API: add "string" version of *_value_multi(), fix segfaults
- config API users: test for *_get_value_multi() segfaults
- for-each-repo: error on bad --config
- config API: have *_multi() return an "int" and take a "dest"
- versioncmp.c: refactor config reading next commit
- config tests: add "NULL" tests for *_get_value_multi()
- config tests: cover blind spots in git_die_config() tests
- for-each-repo tests: test bad --config keys
Assorted config API updates.
Needs review.
source: <cover-v3-0.9-00000000000-20221125T093158Z-avarab@gmail.com>
* ed/fsmonitor-inotify (2022-12-13) 6 commits
- fsmonitor: update doc for Linux
- fsmonitor: test updates
- fsmonitor: enable fsmonitor for Linux
- fsmonitor: implement filesystem change listener for Linux
- fsmonitor: determine if filesystem is local or remote
- fsmonitor: prepare to share code between Mac OS and Linux
Bundled fsmonitor for Linux using inotify API.
Needs review on the updated round.
source: <pull.1352.v5.git.git.1670882286.gitgitgadget@gmail.com>
* jc/spell-id-in-both-caps-in-message-id (2022-12-17) 1 commit
- e-mail workflow: Message-ID is spelled with ID in both capital letters
Consistently spell "Message-ID" as such, not "Message-Id".
Needs review.
source: <xmqqsfhgnmqg.fsf@gitster.g>
* cb/grep-fallback-failing-jit (2022-12-17) 1 commit
- grep: fall back to interpreter mode if JIT fails
In an environment where dynamically generated code is prohibited to
run (e.g. SELinux), failure to JIT pcre patterns is expected. Fall
back to interpreted execution in such a case.
Expecting a reroll.
cf. <62a06c5b-9646-17f8-b4d5-39823d3cc25a@grsecurity.net>
source: <20221216121557.30714-1-minipli@grsecurity.net>
* ad/test-record-count-when-harness-is-in-use (2022-12-25) 1 commit
- test-lib: allow storing counts with test harnesses
Allow summary results from tests to be written to t/test-results
directory even when a test harness like 'prove' is in use.
Needs review.
source: <20221224225200.1027806-1-adam@dinwoodie.org>
* so/diff-merges-more (2022-12-18) 5 commits
- diff-merges: improve --diff-merges documentation
- diff-merges: issue warning on lone '-m' option
- diff-merges: support list of values for --diff-merges
- diff-merges: implement log.diffMerges-m-imply-p config
- diff-merges: implement [no-]hide option and log.diffMergesHide config
Assorted updates to "--diff-merges=X" option.
May want to discard. Breaking compatibility does not seem worth it.
source: <20221217132955.108542-1-sorganov@gmail.com>
--------------------------------------------------
[Cooking]
* ar/dup-words-fixes (2023-01-08) 1 commit
(merged to 'next' on 2023-01-09 at 2a5d4537a2)
+ *: fix typos which duplicate a word
Typofixes.
Will merge to 'master'.
source: <20230107135655.149892-1-rybak.a.v@gmail.com>
* ds/bundle-uri-5 (2023-01-07) 8 commits
- bundle-uri: store fetch.bundleCreationToken
- fetch: fetch from an external bundle URI
- bundle-uri: drop bundle.flag from design doc
- clone: set fetch.bundleURI if appropriate
- bundle-uri: download in creationToken order
- bundle-uri: parse bundle.<id>.creationToken values
- bundle-uri: parse bundle.heuristic=creationToken
- t5558: add tests for creationToken heuristic
(this branch uses ds/bundle-uri-4.)
The bundle-URI subsystem adds support for creation-token heuristics
to help incremental fetches.
Needs review.
source: <pull.1454.git.1673037405.gitgitgadget@gmail.com>
* jk/read-object-cleanup (2023-01-13) 6 commits
(merged to 'next' on 2023-01-13 at 8cbeef4abd)
+ object-file: fix indent-with-space
(merged to 'next' on 2023-01-09 at 19cc3de33e)
+ packfile: inline custom read_object()
+ repo_read_object_file(): stop wrapping read_object_file_extended()
+ read_object_file_extended(): drop lookup_replace option
+ streaming: inline call to read_object_file_extended()
+ object-file: inline calls to read_object()
Code clean-up.
Will merge to 'master'.
source: <Y7l4LsEQcDT9HZ21@coredump.intra.peff.net>
* jk/strncmp-to-api-funcs (2023-01-08) 2 commits
(merged to 'next' on 2023-01-09 at 47395b7c6f)
+ convert trivial uses of strncmp() to skip_prefix()
+ convert trivial uses of strncmp() to starts_with()
Code clean-up.
Will merge to 'master'.
source: <Y7lyga5g2leSmWQd@coredump.intra.peff.net>
* pb/doc-orig-head (2023-01-13) 5 commits
- git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten
- revisions.txt: be explicit about commands writing 'ORIG_HEAD'
- git-merge.txt: mention 'ORIG_HEAD' in the Description
- git-reset.txt: mention 'ORIG_HEAD' in the Description
- git-cherry-pick.txt: do not use 'ORIG_HEAD' in example
Document ORIG_HEAD a bit more.
Will merge to 'next'.
source: <pull.1456.v2.git.1673356521.gitgitgadget@gmail.com>
* tc/cat-file-z-use-cquote (2023-01-08) 1 commit
. cat-file: quote-format name in error when using -z
"cat-file" in the batch mode that is fed NUL-terminated pathnames
learned to cquote them in its error output (otherwise, a funny
pathname with LF in it would break the lines in the output stream).
Breaks t1006.
cf. https://github.com/git/git/actions/runs/3865911497/jobs/6589699288#step:6:1802
source: <20230105062447.2943709-2-toon@iotcl.com>
* cb/grep-pcre-ucp (2023-01-09) 1 commit
- grep: correctly identify utf-8 characters with \{b,w} in -P
"grep -P" learned to use Unicode Character Property to grok
character classes when processing \b and \w etc.
Will merge to 'next'?
source: <20230108155217.2817-1-carenas@gmail.com>
* es/hooks-and-local-env (2023-01-13) 1 commit
- githooks: discuss Git operations in foreign repositories
Doc update for environment variables set when hooks are invoked.
Will merge to 'next'.
source: <pull.1457.v2.git.1673293508399.gitgitgadget@gmail.com>
* ph/parse-date-reduced-precision (2023-01-13) 1 commit
- date.c: allow ISO 8601 reduced precision times
Loosen date parsing heuristics.
Will merge to 'next'.
source: <20230111001003.10916-1-congdanhqx@gmail.com>
* pw/ci-print-failure-name-fix (2023-01-04) 1 commit
(merged to 'next' on 2023-01-08 at 8bb55c12c7)
+ ci(github): restore "print test failures" step name
(cosmetic) CI regression fix.
Will merge to 'master'.
source: <pull.1453.git.1672741640587.gitgitgadget@gmail.com>
* rs/use-enhanced-bre-on-macos (2023-01-08) 1 commit
- use enhanced basic regular expressions on macOS
Newer regex library macOS stopped enabling GNU-like enhanced BRE,
where '\(A\|B\)' works as alternation, unless explicitly asked with
the REG_ENHANCED flag. "git grep" now can be compiled to do so, to
retain the old behaviour.
Under discussion.
cf. <26a0d4ca-3d97-ace4-1a1f-92b1ee6715a6@web.de>
source: <26a0d4ca-3d97-ace4-1a1f-92b1ee6715a6@web.de>
* cw/submodule-status-in-parallel (2023-01-05) 6 commits
- submodule: call parallel code from serial status
- diff-lib: parallelize run_diff_files for submodules
- diff-lib: refactor match_stat_with_submodule
- submodule: move status parsing into function
- submodule: strbuf variable rename
- run-command: add duplicate_output_fn to run_processes_parallel_opts
"git submodule status" learned to run the comparison in submodule
repositories in parallel.
Needs review.
source: <https://lore.kernel.org/git/20221108184200.2813458-1-calvinwan@google.com/>
* kn/attr-from-tree (2023-01-13) 2 commits
- attr: add flag `--source` to work with tree-ish
- t0003: move setup for `--all` into new block
"git check-attr" learned to take an optional tree-ish to read the
.gitattributes file from.
Will merge to 'next'.
source: <cover.1673521102.git.karthik.188@gmail.com>
* ws/single-file-cone (2023-01-05) 1 commit
(merged to 'next' on 2023-01-09 at b6d4d7b905)
+ dir: check for single file cone patterns
The logic to see if we are using the "cone" mode by checking the
sparsity patterns has been tightened to avoid mistaking a pattern
that names a single file as specifying a cone.
Will merge to 'master'.
source: <pull.1446.v2.git.1672734059938.gitgitgadget@gmail.com>
* ds/bundle-uri-4 (2023-01-06) 1 commit
(merged to 'next' on 2023-01-08 at d5b03bdd48)
+ test-bundle-uri: drop unused variables
(this branch is used by ds/bundle-uri-5.)
Code clean-up.
Will merge to 'master'.
source: <Y7fgV5eFx78BHdQ4@coredump.intra.peff.net>
* jk/ext-diff-with-relative (2023-01-06) 3 commits
(merged to 'next' on 2023-01-08 at 5233a7d3ee)
+ diff: drop "name" parameter from prepare_temp_file()
+ diff: clean up external-diff argv setup
+ diff: use filespec path to set up tempfiles for ext-diff
"git diff --relative" did not mix well with "git diff --ext-diff",
which has been corrected.
Will merge to 'master'.
source: <Y7f/YiVu1TgbucDI@coredump.intra.peff.net>
* tb/ci-concurrency (2022-11-08) 1 commit
(merged to 'next' on 2023-01-08 at ab7cdc20b8)
+ ci: avoid unnecessary builds
Avoid unnecessary builds in CI, with settings configured in
ci-config.
Will merge to 'master'.
source: <ff172f1de982f6f79b598e4ac6d5b2964ca4a098.1667931937.git.me@ttaylorr.com>
* tr/am--no-verify (2023-01-05) 1 commit
(merged to 'next' on 2023-01-08 at 4585013067)
+ am: allow passing --no-verify flag
Conditionally skip the pre-applypatch and applypatch-msg hooks when
applying patches with 'git am'.
Will merge to 'master'.
source: <20221130172833.2662751-1-thierry.reding@gmail.com>
* ab/various-leak-fixes (2022-12-30) 20 commits
- push: free_refs() the "local_refs" in set_refspecs()
- receive-pack: free() the "ref_name" in "struct command"
- grep API: plug memory leaks by freeing "header_list"
- grep.c: refactor free_grep_patterns()
- object-file.c: release the "tag" in check_tag()
- connected.c: free(new_pack) in check_connected()
- builtin/merge.c: free "&buf" on "Your local changes..." error
- builtin/merge.c: always free "struct strbuf msg"
- show-branch: free() allocated "head" before return
- commit-graph: fix a parse_options_concat() leak
- http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}()
- http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main()
- worktree: fix a trivial leak in prune_worktrees()
- repack: fix leaks on error with "goto cleanup"
- name-rev: don't xstrdup() an already dup'd string
- various: add missing clear_pathspec(), fix leaks
- clone: use free() instead of UNLEAK()
- commit-graph: use free() instead of UNLEAK()
- bundle.c: don't leak the "args" in the "struct child_process"
- tests: mark tests as passing with SANITIZE=leak
Leak fixes.
Expecting a reroll.
source: <cover-v2-00.20-00000000000-20221230T020341Z-avarab@gmail.com>
* rj/branch-unborn-in-other-worktrees (2023-01-01) 2 commits
- branch: rename orphan branches in any worktree
- branch: description for orphan branch errors
Error messages given when working on an unborn branch that is
checked out in another worktree have been improvved.
source: <ffd675e9-8a64-ae05-fc3b-36ae99092735@gmail.com>
* rs/dup-array (2023-01-09) 5 commits
- use DUP_ARRAY
- add DUP_ARRAY
- do full type check in BARF_UNLESS_COPYABLE
- factor out BARF_UNLESS_COPYABLE
- mingw: make argv2 in try_shell_exec() non-const
Code cleaning.
Will merge to 'next'.
source: <9bc1bd74-f72c-1b43-df7c-950815babb03@web.de>
source: <3e04e283-cad0-7be4-d85c-65d0a52289e2@web.de>
* ab/avoid-losing-exit-codes-in-tests (2022-12-20) 6 commits
- tests: don't lose misc "git" exit codes
- tests: don't lose "git" exit codes in "! ( git ... | grep )"
- tests: don't lose exit status with "test <op> $(git ...)"
- tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
- t/lib-patch-mode.sh: fix ignored exit codes
- auto-crlf tests: don't lose exit code in loops and outside tests
Test clean-up.
Expecting a hopefully minor and final reroll.
cf. <1182283a-4a78-3c99-e716-a8c3e58a5823@web.de>
cf. <xmqqsfhb0vum.fsf@gitster.g>
source: <cover-v4-0.6-00000000000-20221219T101240Z-avarab@gmail.com>
* sk/win32-close-handle-upon-pthread-join (2023-01-04) 2 commits
- win32: close handles of threads that have been joined
- win32: prepare pthread.c for change by formatting
Pthread emulation on Win32 leaked thread handle when a thread is
joined.
Will merge to 'next'?
<source: <pull.1406.v13.git.git.1672762819.gitgitgadget@gmail.com>
* ds/omit-trailing-hash-in-index (2023-01-07) 4 commits
(merged to 'next' on 2023-01-09 at e17ef56485)
+ features: feature.manyFiles implies fast index writes
+ test-lib-functions: add helper for trailing hash
+ read-cache: add index.skipHash config option
+ hashfile: allow skipping the hash function
Introduce an optional configuration to allow the trailing hash that
protects the index file from bit flipping.
Will merge to 'master'.
source: <pull.1439.v5.git.1673022717.gitgitgadget@gmail.com>
* es/t1509-root-fixes (2022-12-09) 3 commits
(merged to 'next' on 2023-01-08 at c922e34bab)
+ t1509: facilitate repeated script invocations
+ t1509: make "setup" test more robust
+ t1509: fix failing "root work tree" test due to owner-check
Test fixes.
Will merge to 'master'.
source: <pull.1425.git.1668999621.gitgitgadget@gmail.com>
* jx/t1301-updates (2022-11-30) 3 commits
- t1301: do not change $CWD in "shared=all" test case
- t1301: use test_when_finished for cleanup
- t1301: fix wrong template dir for git-init
Test updates.
Will merge to 'next'.
source: <20221128130323.8914-1-worldhello.net@gmail.com>
* km/send-email-with-v-reroll-count (2022-11-27) 1 commit
- send-email: relay '-v N' to format-patch
"git send-email -v 3" used to be expanded to "git send-email
--validate 3" when the user meant to pass them down to
"format-patch", which has been corrected.
source: <87edtp5uws.fsf@kyleam.com>
* ja/worktree-orphan (2023-01-13) 4 commits
- worktree add: add hint to direct users towards --orphan
- worktree add: add --orphan flag
- worktree add: refactor opt exclusion tests
- worktree add: include -B in usage docs
'git worktree add' learned how to create a worktree based on an
orphaned branch with `--orphan`.
Will merge to 'next'.
source: <20230109173227.29264-1-jacobabel@nullpo.dev>
* cc/filtered-repack (2022-12-25) 3 commits
- gc: add gc.repackFilter config option
- repack: add --filter=<filter-spec> option
- pack-objects: allow --filter without --stdout
"git repack" learns to discard objects that ought to be retrievable
again from the promisor remote.
May want to discard. Its jaggy edges may be a bit too sharp.
cf. <Y7WTv19aqiFCU8au@ncase>
source: <20221221040446.2860985-1-christian.couder@gmail.com>
* mc/credential-helper-auth-headers (2022-12-13) 8 commits
- t5556: add HTTP authentication tests
- test-http-server: add simple authentication
- test-http-server: pass Git requests to http-backend
- test-http-server: add HTTP request parsing
- test-http-server: add HTTP error response function
- test-http-server: add stub HTTP server test helper
- credential: add WWW-Authenticate header to cred requests
- http: read HTTP WWW-Authenticate response headers
Extending credential helper protocol.
Waiting for review responses (or a reroll).
cf. <1dc44716-2550-47de-e666-9972b102905d@github.com>
source: <pull.1352.v4.git.1670880984.gitgitgadget@gmail.com>
^ permalink raw reply
* Re: [PATCH v1 3/3] t7527: use test_when_finished in 'case insensitive+preserving'
From: Eric Sunshine @ 2023-01-14 9:43 UTC (permalink / raw)
To: Andrei Rybak; +Cc: git, Jeff Hostetler
In-Reply-To: <20230111233242.16870-4-rybak.a.v@gmail.com>
On Wed, Jan 11, 2023 at 7:00 PM Andrei Rybak <rybak.a.v@gmail.com> wrote:
> Most tests in t7527-builtin-fsmonitor.sh that start a daemon, use the
> helper function test_when_finished with stop_daemon_delete_repo.
> Function stop_daemon_delete_repo explicitly stops the daemon. Calling
> it via test_when_finished is needed for tests that don't check daemon's
> automatic shutdown logic [1] and it is needed to avoid daemons being
> left running in case of breakage of the logic of automatic shutdown of
> the daemon.
>
> Unlike these tests, test 'case insensitive+preserving' added in [2] has
> a call to function test_when_finished commented out. It was commented
> out in all versions of the patch [2] during development [3]. This seems
> to not be intentional, because neither commit message in [2], nor the
> comment above the test mention this line being commented out. Compare
> it, for example, to "# unicode_debug=true" which is explicitly described
> by a documentation comment above it.
>
> Uncomment test_when_finished for stop_daemon_delete_repo in test 'case
> insensitive+preserving' to ensure that daemons are not left running in
> cases when automatic shutdown logic of daemon itself is broken.
>
> Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
> ---
> diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh
> @@ -910,7 +910,7 @@ test_expect_success "submodule absorbgitdirs implicitly starts daemon" '
> test_expect_success CASE_INSENSITIVE_FS 'case insensitive+preserving' '
> -# test_when_finished "stop_daemon_delete_repo test_insensitive" &&
> + test_when_finished "stop_daemon_delete_repo test_insensitive" &&
Nice. Thanks for working on this (and the series as a whole) in
response to a very tangential comment of mine[1] when replying to an
unrelated patch of yours.
[1]: https://lore.kernel.org/git/CAPig+cTgUPWxMox_nSka52dML6_GHUUoY4HCtcq7+7J0oEyeNw@mail.gmail.com/
^ permalink raw reply
* bugreport: "git checkout -B" allows checking out one branch across multiple worktrees
From: Jinwook Jeong @ 2023-01-14 9:45 UTC (permalink / raw)
To: git
What did you do before the bug happened? (Steps to reproduce your issue)
1. `cd` into any git repo that has at least one commit.
2. Identify the current branch, say main
3. $ git branch foo # a new branch
4. $ git worktree add ../new_worktree foo
5. $ cd ../new_worktree
6. $ git checkout -B master HEAD
What did you expect to happen? (Expected behavior)
git prints out "Fatal: 'main' is already checked out at ..." (or
similar message that informs me that I'm not allowed to doubly
checkout one branch)
What happened instead? (Actual behavior)
The new_worktree successfully changes its current branch to master,
which is already held by another worktree.
Anything else you want to add:
https://www.git-scm.com/docs/git-checkout#Documentation/git-checkout.txt-emgitcheckoutem-b-Bltnew-branchgtltstart-pointgt
According to the documentation, "git checkout -B BRANCH START" is the
transactionally equivalent of:
git branch -f BRANCH START
git checkout BRANCH
When I ran the first command in place of the step 6 of the above
reproducing procedure, git refused to carry on;
I suppose that this is the intended behavior for "git checkout -B".
[System Info]
git version:
git version 2.39.0
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov 6 23:31:13
PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 arm64
compiler info: clang: 14.0.0 (clang-1400.0.29.202)
libc info: no libc information available
$SHELL (typically, interactive shell): /opt/homebrew/bin/bash
[Enabled Hooks]
not run from a git repository - no hooks to show
^ permalink raw reply
* Re: [PATCH v4] sparse-checkout.txt: new document with sparse-checkout directions
From: ZheNing Hu @ 2023-01-14 10:18 UTC (permalink / raw)
To: Elijah Newren
Cc: Elijah Newren via GitGitGadget, git, Victoria Dye, Derrick Stolee,
Shaoxuan Yuan, Matheus Tavares, Glen Choo, Martin von Zweigbergk
In-Reply-To: <CABPp-BHaKH4sOPx2tx7CU+Uymvtu=mU1ZweGBDdWvhb-FgGA_Q@mail.gmail.com>
Elijah Newren <newren@gmail.com> 于2022年11月16日周三 13:49写道:
> [...]
> > > + The fact that files can move between the 'tracked' and 'untracked'
> > > + categories means some commands will have to treat untracked files
> > > + differently. But if we have to treat untracked files differently,
> > > + then additional commands may also need changes:
> > > +
> > > + * status
> > > + * clean
> > > +
> >
> > I'm a bit worried about git status, because it's used in many shells
> > (e.g. zsh) i
> > in the git prompt function. Its default behavior is restricted, otherwise users
> > may get blocked when they use zsh to cd to that directory. I don't know how
> > to reproduce this problem (since the scenario is built on checkout to a local
> > unborn branch).
>
> Could you elaborate? I'm not sure if you are talking about an
> existing problem that you are worried about being exacerbated, or a
> hypothetical problem that could occur with changes. Further, your
> wording is so vague about the problem, that I have no idea what its
> nature is or whether any changes to status would even possibly have
> any bearing on it. But the suggested changes to git status are
> simply:
>
I find this special case, it will fetch some blobs when "git status".
First, we init a git repository, then set sparse specification to "*.js" with
no-cone mode, then use blob:none filter to fetch all commits and trees,
and finally checkout to the default branch.
#!/bin/sh
rm -rf sparse-checkout-example
git init sparse-checkout-example
git -C sparse-checkout-example remote add origin
git@github.com:derrickstolee/sparse-checkout-example.git
git -C sparse-checkout-example sparse-checkout set --no-cone *.js
git -C sparse-checkout-example fetch origin --filter=blob:none main
git -C sparse-checkout-example branch --track main origin/main
git -C sparse-checkout-example checkout main
Then let's do a git status, which some zsh git plugin
will do when user "cd" the git repository.
# git -C sparse-checkout-exmaple status
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Receiving objects: 100% (1/1), 416 bytes | 416.00 KiB/s, done.
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Receiving objects: 100% (1/1), 160 bytes | 160.00 KiB/s, done.
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Receiving objects: 100% (1/1), 2.01 KiB | 2.01 MiB/s, done.
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Receiving objects: 100% (1/1), 120 bytes | 120.00 KiB/s, done.
On branch main
Your branch is up to date with 'origin/main'.
You are in a sparse checkout with 8% of tracked files present.
It took 17.00 seconds to enumerate untracked files. 'status -uno'
may speed it up, but you have to be careful not to forget to add
new files yourself (see 'git help status').
nothing to commit, working tree clean
Yeah, here it fetches four blobs, and takes 17s!!!
So what blobs are we fetching?
GIT_TRACE_PACKET=1 git -C sparse-checkout-example status
...
18:02:32.989231 pkt-line.c:80 packet: fetch> want
dff85a65c0ef4b50a4c01bdd4a247b974bc45f90
...
18:02:37.059203 pkt-line.c:80 packet: fetch> want
f07ead02d13f62414589b1f1b891bb6a764ec91f
...
18:02:40.868899 pkt-line.c:80 packet: fetch> want
3c4efe206bd0e7230ad0ae8396a3c883c8207906
...
18:02:44.961809 pkt-line.c:80 packet: fetch> want
6590681af7e177dc71fe08648c4bbf4223b82866
Then let's we look what's the blob:
git log --find-object=dff85a65c0ef4b50a4c01bdd4a247b974bc45f90 --stat
commit 8ec229339caad56eb849c67361a9699004564177
Author: Derrick Stolee <dstolee@microsoft.com>
Date: Mon Dec 30 13:30:27 2019 -0500
Add twbs/bootstrap
web/browser/.gitignore | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
git log --find-object=f07ead02d13f62414589b1f1b891bb6a764ec91f --stat
commit 9c5a31030de62355410a322923e33e90a00032f6
Author: Derrick Stolee <dstolee@microsoft.com>
Date: Mon Dec 30 13:31:06 2019 -0500
Add artsy/artsy.github.io
web/editor/.gitignore | 13 +++++++++++++
1 file changed, 13 insertions(+)
Yeah, it seems that git status fetch these .gitigore files.
So what's the wrong here?
^ permalink raw reply
* Re: git.functions to improve the git users experience in your bash
From: Roberto A. Foglietta @ 2023-01-14 11:25 UTC (permalink / raw)
To: git
In-Reply-To: <CAJGKYO5UGmFZjZ2ucFY=1MojzVur69EjRgy=aWW7wnhZ6=DaVA@mail.gmail.com>
On Thu, 5 Jan 2023 at 18:50, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> Hi all,
>
> today, I have published this project which aims to deliver some
> advanced functions for git and also a lot of smart shortcuts for the
> most frequently used git commands. I hope you will like it and
> possibly also contribute to its future development with your feedback.
> At the moment, the project is limited to support bash. However, if
> someone is interested in using it under dash, I will be happy to plan
> a porting.
>
> https://github.com/robang74/git-functions
>
It is available on the 'main' branch the v0.4-rc1 for those who like
to try it. I suggest not installing it but just try over a spendible
repository, just in case. The README.md lists and briefly explains all
the functions that wrap git.
Best regards, R-
^ permalink raw reply
* Re: What's cooking in git.git (Jan 2023, #04; Sat, 14)
From: Jeff King @ 2023-01-14 12:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <xmqqilh9ms1p.fsf@gitster.g>
On Sat, Jan 14, 2023 at 12:36:18AM -0800, Junio C Hamano wrote:
> * ab/test-env-helper (2023-01-13) 1 commit
> - env-helper: move this built-in to to "test-tool env-helper"
>
> Remove "git env--helper" and demote it to a test-tool subcommand.
>
> Will merge to 'next'.
> source: <patch-1.1-e662c570f1d-20230112T155226Z-avarab@gmail.com>
There's a typo in the subject: s/to to/to/. Not a big deal, but since it
hasn't quite hit next yet, maybe worth fixing.
> * jk/interop-error (2023-01-13) 1 commit
> - t/interop: report which vanilla git command failed
>
> Test helper improvement.
>
> Will merge to 'next'.
> source: <Y8A3yGeJl0TCDNqe@coredump.intra.peff.net>
I was curious if you'd stick this one with Ævar's, since they're
somewhat related. But it's fine to queue them independently. Mine makes
finding the bug easier, and his fixes it. ;)
-Peff
^ permalink raw reply
* Re: BUG: git grep behave oddly with alternatives
From: Diomidis Spinellis @ 2023-01-14 12:45 UTC (permalink / raw)
To: René Scharfe, Junio C Hamano,
Ævar Arnfjörð Bjarmason
Cc: Jeff King, Marco Nenciarini, git
In-Reply-To: <b2e597aa-044d-e136-43b9-afc84a1e3794@web.de>
On 14-Jan-23 10:31, René Scharfe wrote:
> Am 14.01.23 um 07:44 schrieb René Scharfe:
>> Am 13.01.23 um 18:19 schrieb Junio C Hamano:
>>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>>
>>>> On Thu, Jan 12 2023, Jeff King wrote:
>>>> There's a couple of ways out of this that I don't see in this thread:
>>>>
>>>> - Declare it not a problem: We have -G, -E and -P to map to BRE, ERE and
>>>> PCRE. One view is to say the first two must match POSIX, another is
>>>> tha whatever the platform thinks they should do is how they should
>>>> act.
>>>
>>> ... this view. The story "BRE and ERE work via what system
>>> libraries provide, and 'git grep' matches what system grep' does" is
>>> an easy to understand view.
>>
>> That was my stance in my first reply as well. But 3632cfc248 (Use
>> compatibility regex library for OSX/Darwin, 2008-09-07) explicitly
>> added alternation support for BREs on macOS, and 1819ad327b (grep: fix
>> multibyte regex handling under macOS, 2022-08-26) removed it seemingly
>> by accident. And grep(1) does support them on macOS 13.1:
Indeed, I removed the alternation handling functionality by accident. I
was not aware of the BRE-handling difference between the GNU and the
macOS native regex library. I think having git-grep behave the same as
grep(1) on each platform is consistent with the principle of least
astonishment (POLA). This would mean that on macOS plain git-grep
should use enhanced basic REs as proposed in René's patch.
Diomidis
^ permalink raw reply
* Re: [PATCH] ci: do not die on deprecated-declarations warning
From: Ramsay Jones @ 2023-01-14 14:29 UTC (permalink / raw)
To: Junio C Hamano, git
Cc: Ævar Arnfjörð Bjarmason, Adam Dinwoodie
In-Reply-To: <xmqqv8l9n5fj.fsf@gitster.g>
Hi Junio,
On 14/01/2023 03:47, Junio C Hamano wrote:
> Like a recent GitHub CI run on linux-musl [1] shows, we seem to be
> getting a bunch of errors of the form:
>
> Error: http.c:1002:9: 'CURLOPT_REDIR_PROTOCOLS' is deprecated:
> since 7.85.0. Use CURLOPT_REDIR_PROTOCOLS_STR
> [-Werror=deprecated-declarations]
Yes, on 30-Dec-2022 I updated my cygwin installation, which updated
the curl package(s) from v7.86.0 to v7.87.0, and caused my build
to fail. I had a quick look at the new 'curl.h' header file and
disabled the deprecation warnings to fix my build. I used vim to
add the following to my config.mak:
CFLAGS += -DCURL_DISABLE_DEPRECATION
.. and then promptly forgot about it for a couple of weeks! :)
As it happens, just last night I started to look at fixing the code
to avoid the deprecated 'options'. However, if you are not interested
in doing that, I can stop looking into that. ;)
[I was probably doing it wrong anyway - I was just #ifdef-ing code
based on the curl version number, rather than setting something up
in the git-curl-compat.h header file; I haven't grokked that yet.]
>
> For some of them, it may be reasonable to follow the deprecation
> notice and update the code, but some symbols like the above is not.
>
> According to the release table [2], 7.85.0 that deprecates
> CURLOPT_REDIR_PROTOCOLS was released on 2022-08-31, less than a year
> ago, and according to the symbols-in-versions table [3],
> CURLOPT_REDIR_PROTOCOLS_STR was introduced in 7.85.0, so it will
> make us incompatible with anything older than a year if we rewrote
> the call as the message suggests.
>
> Make sure that we won't break the build when -Wdeprecated-declarations
> triggers.
>
> [1] https://github.com/git/git/actions/runs/3915509922/jobs/6693756050
> [2] https://curl.se/docs/releases.html
> [3] https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> config.mak.dev | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/config.mak.dev b/config.mak.dev
> index 981304727c..afcffa6a04 100644
> --- a/config.mak.dev
> +++ b/config.mak.dev
> @@ -69,6 +69,15 @@ DEVELOPER_CFLAGS += -Wno-missing-braces
> endif
> endif
>
> +# Libraries deprecate symbols while retaining them for a long time to
> +# keep software working with both older and newer versions of them.
> +# Getting warnings does help the developers' awareness, but we cannot
> +# afford to update too aggressively. E.g. CURLOPT_REDIR_PROTOCOLS_STR
> +# is only available in 7.85.0 that deprecates CURLOPT_REDIR_PROTOCOLS
> +# but we cannot rewrite the uses of the latter with the former until
> +# 7.85.0, which was released in August 2022, becomes ubiquitous.
> +DEVELOPER_CFLAGS += -Wno-error=deprecated-declarations
> +
> # Old versions of clang complain about initializaing a
> # struct-within-a-struct using just "{0}" rather than "{{0}}". This
> # error is considered a false-positive and not worth fixing, because
Rather than suppressing 'deprecated-declarations' globally, we could
just add '-DCURL_DISABLE_DEPRECATION' to the compilation of http.c,
http-push.c and remote-curl.c; similar to how we use target specific
rules to pass '-DCURL_DISABLE_TYPECHECK' to sparse (only) to a similar
set of files.
I haven't tried that yet (so famous last words...).
Sorry for not looking into this (and notifying the list) sooner.
ATB,
Ramsay Jones
^ permalink raw reply
* [PATCH] ls-tree: fix expansion of repeated %(path)
From: René Scharfe @ 2023-01-14 14:37 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason
expand_show_tree() borrows the base strbuf given to us by read_tree() to
build the full path of the current entry when handling %(path). Only
its indirect caller, show_tree_fmt(), removes the added entry name.
That works fine as long as %(path) is only included once in the format
string, but accumulates duplicates if it's repeated:
$ git ls-tree --format='%(path) %(path) %(path)' HEAD M*
Makefile MakefileMakefile MakefileMakefileMakefile
Reset the length after each use to get the same expansion every time;
here's the behavior with this patch:
$ ./git ls-tree --format='%(path) %(path) %(path)' HEAD M*
Makefile Makefile Makefile
Signed-off-by: René Scharfe <l.s.r@web.de>
---
builtin/ls-tree.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index c3ea09281a..120fff9fa0 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -98,9 +98,11 @@ static size_t expand_show_tree(struct strbuf *sb, const char *start,
const char *prefix = chomp_prefix ? ls_tree_prefix : NULL;
struct strbuf quoted = STRBUF_INIT;
struct strbuf sbuf = STRBUF_INIT;
+ size_t baselen = data->base->len;
strbuf_addstr(data->base, data->pathname);
name = relative_path(data->base->buf, prefix, &sbuf);
quote_c_style(name, "ed, NULL, 0);
+ strbuf_setlen(data->base, baselen);
strbuf_addbuf(sb, "ed);
strbuf_release(&sbuf);
strbuf_release("ed);
@@ -144,7 +146,6 @@ static int show_recursive(const char *base, size_t baselen, const char *pathname
static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *context UNUSED)
{
- size_t baselen;
int recurse = 0;
struct strbuf sb = STRBUF_INIT;
enum object_type type = object_type(mode);
@@ -164,12 +165,10 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
if (type == OBJ_BLOB && (ls_options & LS_TREE_ONLY))
return 0;
- baselen = base->len;
strbuf_expand(&sb, format, expand_show_tree, &data);
strbuf_addch(&sb, line_termination);
fwrite(sb.buf, sb.len, 1, stdout);
strbuf_release(&sb);
- strbuf_setlen(base, baselen);
return recurse;
}
--
2.39.0
^ permalink raw reply related
* Re: [PATCH] ci: do not die on deprecated-declarations warning
From: Jeff King @ 2023-01-14 14:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ramsay Jones, git
In-Reply-To: <xmqqv8l9n5fj.fsf@gitster.g>
On Fri, Jan 13, 2023 at 07:47:12PM -0800, Junio C Hamano wrote:
> Like a recent GitHub CI run on linux-musl [1] shows, we seem to be
> getting a bunch of errors of the form:
>
> Error: http.c:1002:9: 'CURLOPT_REDIR_PROTOCOLS' is deprecated:
> since 7.85.0. Use CURLOPT_REDIR_PROTOCOLS_STR
> [-Werror=deprecated-declarations]
>
> For some of them, it may be reasonable to follow the deprecation
> notice and update the code, but some symbols like the above is not.
Heh, I was just poking at this myself.
> According to the release table [2], 7.85.0 that deprecates
> CURLOPT_REDIR_PROTOCOLS was released on 2022-08-31, less than a year
> ago, and according to the symbols-in-versions table [3],
> CURLOPT_REDIR_PROTOCOLS_STR was introduced in 7.85.0, so it will
> make us incompatible with anything older than a year if we rewrote
> the call as the message suggests.
Yeah, we'd definitely have to keep code covering both versions for a
while. Which is a good reason to punt until the deprecated option is
actually removed, since enough time may have passed by then that we can
avoid having to maintain both versions.
The other thing that makes me care less about this deprecation is that
the deprecation warning in the manpage says:
We strongly recommend using CURLOPT_REDIR_PROTOCOLS_STR(3) instead
because this option cannot control all available protocols!
But we don't care about that. We are setting a very small and vanilla
subset of the possible protocols, and the non-STR version is fine for
that.
> +# Libraries deprecate symbols while retaining them for a long time to
> +# keep software working with both older and newer versions of them.
> +# Getting warnings does help the developers' awareness, but we cannot
> +# afford to update too aggressively. E.g. CURLOPT_REDIR_PROTOCOLS_STR
> +# is only available in 7.85.0 that deprecates CURLOPT_REDIR_PROTOCOLS
> +# but we cannot rewrite the uses of the latter with the former until
> +# 7.85.0, which was released in August 2022, becomes ubiquitous.
> +DEVELOPER_CFLAGS += -Wno-error=deprecated-declarations
That's a pretty broad hammer. And I think it may stomp on the hack to
rely on deprecated() in the UNUSED macro.
As Ramsay suggested, we could probably use CURL_DISABLE_DEPRECATION to
limit this just to the problematic case. An even more focused option is
to use curl's helper here:
diff --git a/http.c b/http.c
index 17d954dd95..21891493d9 100644
--- a/http.c
+++ b/http.c
@@ -1,3 +1,4 @@
+#define CURL_DISABLE_TYPECHECK 1
#include "git-compat-util.h"
#include "git-curl-compat.h"
#include "http.h"
@@ -979,10 +980,12 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
- curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
- get_curl_allowed_protocols(0));
- curl_easy_setopt(result, CURLOPT_PROTOCOLS,
- get_curl_allowed_protocols(-1));
+ CURL_IGNORE_DEPRECATION(
+ curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
+ get_curl_allowed_protocols(0));
+ curl_easy_setopt(result, CURLOPT_PROTOCOLS,
+ get_curl_allowed_protocols(-1));
+ )
if (getenv("GIT_CURL_VERBOSE"))
http_trace_curl_no_data();
setup_curl_trace(result);
though I think that was introduced only in 7.87.0 along with the
deprecation warnings themselves, so we'd need to have a fallback like:
#ifndef CURL_IGNORE_DEPRECATION(x)
#define CURL_IGNORE_DEPRECATION(x) x
#endif
-Peff
^ permalink raw reply related
* test_pause giving '__git_ps1: not found' warning
From: Philip Oakley @ 2023-01-14 14:54 UTC (permalink / raw)
To: Git List, Philippe Blain, Elijah Newren; +Cc: Philip Oakley
I was trying to refine a test_expect_failure test [1] and tried
inserting a `test_pause &&` test line [2].
I then found, when it paused, I was repeatedly given the warning line
/bin/sh: 1: __git_ps1: not found
in the terminal until I expected the test shell.
my PS1 is working normally in the terminal, but not here. Is this
expected, or do I need to set up anything else?
Normally I'm on Git for Windows, but this was on my old laptop (Acer
7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away.
The basic sequence was
~$ cd repos/git
~/repos/git (doctrunc *)$ cd t
~/repos/git/t (doctrunc *)$ ./t4205-log-pretty-formats.sh -i -x -v
Initialized empty Git repository in /home/philip/repos/git/t/trash
directory.t4205-log-pretty-formats/.git/
[... ...]
+ git log --format=%<(5,mtrunc)%s -4
+ test_pause
+ PAUSE_TERM=dumb
+ PAUSE_SHELL=/bin/sh
+ PAUSE_HOME=/home/philip/repos/git/t/trash
directory.t4205-log-pretty-formats
+ test 0 != 0
+ TERM=dumb HOME=/home/philip/repos/git/t/trash
directory.t4205-log-pretty-formats /bin/sh
/bin/sh: 1: __git_ps1: not found
\w$ git status
On branch source-b
[...]
nothing added to commit but untracked files present (use "git add" to track)
/bin/sh: 1: __git_ps1: not found
I added the gits status to see when/where the warning was emitted.
[1]
https://github.com/PhilipOakley/git/blob/doctrunc/t/t4205-log-pretty-formats.sh#L1021-L1046
[2] https://github.com/git/git/blob/master/t/test-lib-functions.sh#L137-L188
Any suggestions as to how to set this up correctly to avoid the warning?
--
Philip
^ 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