* Re: [PATCH v2 1/1] abspath_part_inside_repo: respect core.fileMode
From: Torsten Bögershausen @ 2018-12-25 10:42 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget
Cc: git, Junio C Hamano, Johannes Schindelin
In-Reply-To: <3eaec10c46bdb1a4a1795ae16a76cef15d541ff5.1545690845.git.gitgitgadget@gmail.com>
Should it be
s/respect core.fileMode/respect core.ignoreCase/
in the header line ?
^ permalink raw reply
* Re: [PATCH v3 1/1] abspath_part_inside_repo: respect core.fileMode
From: Junio C Hamano @ 2018-12-25 8:46 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin
In-Reply-To: <xmqqftumb8zv.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
> the resulting index entry is "blub" or "BLUB". Shouldn't we verify
> that "git add" adds an expected path to the index, instead of
> blindly trusting that it says "Yeah, I did as I was told" with its
> exit status? Would we be adding 'blub' as that is what we told
> 'git' to add, or would it be 'BLUB' as that is what exists on the
> filesystem that is case insensitive but case preserving?
Needless to say, the last part of the above is a mere thetorical
question, and I am not questioning the established behaviour or
suggesting to "improve" it. On a case insensitive filesystem, we
trust what readdir() gave us (but match them with pathspec case
insensitively) for a new path that is not in the index. When we
update the contents of a path that is already in the index, we
preserve the case in the index, even when readdir() reports the same
path in different case (iow, we trust the case in the index more
than what readdir() gives us)..
What I am wondering in the above is if we should document that in
the test, perhaps with a simple
git ls-files blub >actual &&
echo BLUB >expect &&
test_cmp expect actual
or something like that.
^ permalink raw reply
* Re: [PATCH v3 1/1] abspath_part_inside_repo: respect core.fileMode
From: Junio C Hamano @ 2018-12-25 3:06 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin
In-Reply-To: <b935e11d21fc2a34953d1fc651ea09f1a4c1a769.1545692162.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> diff --git a/setup.c b/setup.c
> index 1be5037f12..291bfb2128 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
> off = offset_1st_component(path);
>
> /* check if work tree is already the prefix */
> - if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
> + if (wtlen <= len && !fspathncmp(path, work_tree, wtlen)) {
> if (path[wtlen] == '/') {
> memmove(path, path + wtlen + 1, len - wtlen);
> return 0;
> @@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
> path++;
> if (*path == '/') {
> *path = '\0';
> - if (strcmp(real_path(path0), work_tree) == 0) {
> + if (fspathcmp(real_path(path0), work_tree) == 0) {
> memmove(path0, path + 1, len - (path - path0));
> return 0;
> }
> @@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
> }
>
> /* check whole path */
> - if (strcmp(real_path(path0), work_tree) == 0) {
> + if (fspathcmp(real_path(path0), work_tree) == 0) {
> *path0 = '\0';
> return 0;
> }
So the idea is that the path to the top level of the working tree
must be compared with fspath[n]cmp() to what was given. After
stripping that prefix, the caller uses the result just like it uses
a non-absolute path, which is why the necessary changes are isolated
to this function.
Makes sense.
> diff --git a/t/t3700-add.sh b/t/t3700-add.sh
> index 37729ba258..be582a513b 100755
> --- a/t/t3700-add.sh
> +++ b/t/t3700-add.sh
> @@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
> test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
> '
>
> +test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
> + path="$(pwd)/BLUB" &&
> + touch "$path" &&
> + downcased="$(echo "$path" | tr A-Z a-z)" &&
> + git add "$downcased"
> +'
One problem with the above test is that it leaves it unspecified if
the resulting index entry is "blub" or "BLUB". Shouldn't we verify
that "git add" adds an expected path to the index, instead of
blindly trusting that it says "Yeah, I did as I was told" with its
exit status? Would we be adding 'blub' as that is what we told
'git' to add, or would it be 'BLUB' as that is what exists on the
filesystem that is case insensitive but case preserving?
On a project whose participants all are on case insensitive
filesystems, the above does not matter by definition, but once a
project wants to work with their case sensitive friends, it starts
to matter.
Other than that, looks good to me.
Thanks.
> +
> test_done
^ permalink raw reply
* Re: [PATCH] log: add %S option (like --source) to log --format
From: Issac Trotts @ 2018-12-25 2:12 UTC (permalink / raw)
To: Jeff King; +Cc: git, Noemi Mercado, Issac Trotts
In-Reply-To: <20181222222224.GA15914@sigill.intra.peff.net>
Got it, sounds good.
On Sat, Dec 22, 2018 at 2:22 PM Jeff King <peff@peff.net> wrote:
>
> On Thu, Dec 20, 2018 at 09:24:10PM -0800, Issac Trotts wrote:
>
> > Hi all, friendly ping. Is there still interest in merging this patch?
>
> Yes, but I think people are largely absent for holidays at this point.
> If there hasn't been any movement on it, I'll try to review after Jan
> 5th (it also wouldn't hurt to re-post around then).
>
> -Peff
^ permalink raw reply
* [PATCH v3 0/1] Make abspath() aware of case-insensitive filesystems
From: Johannes Schindelin via GitGitGadget @ 2018-12-24 22:56 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
In-Reply-To: <pull.104.v2.git.gitgitgadget@gmail.com>
It is completely legitimate these days to call git add with absolute paths.
Of course, on a case-insensitive file system, users rightfully expect the
argument to be handled case-insensitively, too. This patch makes it so.
Git for Windows carried this patch for over one and a half years already, I
think it is time to get it into git.git.
Change since v2:
* Replaced MINGW prerequisite in the test by CASE_INSENSITIVE_FS. v1 was
sent out without a change by mistake. Sorry.
Johannes Schindelin (1):
abspath_part_inside_repo: respect core.fileMode
setup.c | 6 +++---
t/t3700-add.sh | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
base-commit: b21ebb671bb7dea8d342225f0d66c41f4e54d5ca
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-104%2Fdscho%2Fcase-insensitive-abspath-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-104/dscho/case-insensitive-abspath-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/104
Range-diff vs v2:
1: 3eaec10c46 ! 1: b935e11d21 abspath_part_inside_repo: respect core.fileMode
@@ -47,7 +47,7 @@
test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
'
-+test_expect_success MINGW 'path is case-insensitive' '
++test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
+ path="$(pwd)/BLUB" &&
+ touch "$path" &&
+ downcased="$(echo "$path" | tr A-Z a-z)" &&
--
gitgitgadget
^ permalink raw reply
* [PATCH v3 1/1] abspath_part_inside_repo: respect core.fileMode
From: Johannes Schindelin via GitGitGadget @ 2018-12-24 22:56 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Johannes Schindelin
In-Reply-To: <pull.104.v3.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.
This fixes https://github.com/git-for-windows/git/issues/735
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
setup.c | 6 +++---
t/t3700-add.sh | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/setup.c b/setup.c
index 1be5037f12..291bfb2128 100644
--- a/setup.c
+++ b/setup.c
@@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
off = offset_1st_component(path);
/* check if work tree is already the prefix */
- if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
+ if (wtlen <= len && !fspathncmp(path, work_tree, wtlen)) {
if (path[wtlen] == '/') {
memmove(path, path + wtlen + 1, len - wtlen);
return 0;
@@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
path++;
if (*path == '/') {
*path = '\0';
- if (strcmp(real_path(path0), work_tree) == 0) {
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
memmove(path0, path + 1, len - (path - path0));
return 0;
}
@@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
}
/* check whole path */
- if (strcmp(real_path(path0), work_tree) == 0) {
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
*path0 = '\0';
return 0;
}
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 37729ba258..be582a513b 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
'
+test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
+ path="$(pwd)/BLUB" &&
+ touch "$path" &&
+ downcased="$(echo "$path" | tr A-Z a-z)" &&
+ git add "$downcased"
+'
+
test_done
--
gitgitgadget
^ permalink raw reply related
* [PATCH v2 1/1] abspath_part_inside_repo: respect core.fileMode
From: Johannes Schindelin via GitGitGadget @ 2018-12-24 22:34 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Johannes Schindelin
In-Reply-To: <pull.104.v2.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.
This fixes https://github.com/git-for-windows/git/issues/735
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
setup.c | 6 +++---
t/t3700-add.sh | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/setup.c b/setup.c
index 1be5037f12..291bfb2128 100644
--- a/setup.c
+++ b/setup.c
@@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
off = offset_1st_component(path);
/* check if work tree is already the prefix */
- if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
+ if (wtlen <= len && !fspathncmp(path, work_tree, wtlen)) {
if (path[wtlen] == '/') {
memmove(path, path + wtlen + 1, len - wtlen);
return 0;
@@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
path++;
if (*path == '/') {
*path = '\0';
- if (strcmp(real_path(path0), work_tree) == 0) {
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
memmove(path0, path + 1, len - (path - path0));
return 0;
}
@@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
}
/* check whole path */
- if (strcmp(real_path(path0), work_tree) == 0) {
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
*path0 = '\0';
return 0;
}
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 37729ba258..8ee4fc70ad 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
'
+test_expect_success MINGW 'path is case-insensitive' '
+ path="$(pwd)/BLUB" &&
+ touch "$path" &&
+ downcased="$(echo "$path" | tr A-Z a-z)" &&
+ git add "$downcased"
+'
+
test_done
--
gitgitgadget
^ permalink raw reply related
* [PATCH v2 0/1] Make abspath() aware of case-insensitive filesystems
From: Johannes Schindelin via GitGitGadget @ 2018-12-24 22:34 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
In-Reply-To: <pull.104.git.gitgitgadget@gmail.com>
It is completely legitimate these days to call git add with absolute paths.
Of course, on a case-insensitive file system, users rightfully expect the
argument to be handled case-insensitively, too. This patch makes it so.
Git for Windows carried this patch for over one and a half years already, I
think it is time to get it into git.git.
Change since v1:
* Replaced MINGW prerequisite in the test by CASE_INSENSITIVE_FS.
Johannes Schindelin (1):
abspath_part_inside_repo: respect core.fileMode
setup.c | 6 +++---
t/t3700-add.sh | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
base-commit: b21ebb671bb7dea8d342225f0d66c41f4e54d5ca
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-104%2Fdscho%2Fcase-insensitive-abspath-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-104/dscho/case-insensitive-abspath-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/104
Range-diff vs v1:
1: 4fb5de504e = 1: 3eaec10c46 abspath_part_inside_repo: respect core.fileMode
--
gitgitgadget
^ permalink raw reply
* [PATCH 2/2] Rebase: Run post-checkout hook on checkout
From: orgads @ 2018-12-24 21:24 UTC (permalink / raw)
To: git; +Cc: Orgad Shaneh
In-Reply-To: <20181224212425.16596-1-orgads@gmail.com>
From: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
builtin/rebase.c | 11 +++++++++--
t/t5403-post-checkout-hook.sh | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b5c99ec10c..7f7a2c738e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -530,6 +530,7 @@ static int run_specific_rebase(struct rebase_options *opts)
#define RESET_HEAD_DETACH (1<<0)
#define RESET_HEAD_HARD (1<<1)
+#define RESET_HEAD_RUN_HOOK (1<<2)
static int reset_head(struct object_id *oid, const char *action,
const char *switch_to_branch, unsigned flags,
@@ -537,6 +538,7 @@ static int reset_head(struct object_id *oid, const char *action,
{
unsigned detach_head = flags & RESET_HEAD_DETACH;
unsigned reset_hard = flags & RESET_HEAD_HARD;
+ unsigned run_hook = flags & RESET_HEAD_RUN_HOOK;
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
@@ -636,6 +638,10 @@ static int reset_head(struct object_id *oid, const char *action,
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
UPDATE_REFS_MSG_ON_ERR);
}
+ if (run_hook)
+ run_hook_le(NULL, "post-checkout",
+ oid_to_hex(orig ? orig : &null_oid),
+ oid_to_hex(oid), "1", NULL);
leave_reset_head:
strbuf_release(&msg);
@@ -1465,7 +1471,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
options.switch_to);
if (reset_head(&oid, "checkout",
- options.head_name, 0,
+ options.head_name,
+ RESET_HEAD_RUN_HOOK,
NULL, buf.buf) < 0) {
ret = !!error(_("could not switch to "
"%s"),
@@ -1539,7 +1546,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
strbuf_addf(&msg, "%s: checkout %s",
getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
if (reset_head(&options.onto->object.oid, "checkout", NULL,
- RESET_HEAD_DETACH, NULL, msg.buf))
+ RESET_HEAD_DETACH | RESET_HEAD_RUN_HOOK, NULL, msg.buf))
die(_("Could not detach HEAD"));
strbuf_release(&msg);
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index 9f9a5163c5..5b4e582caa 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -13,6 +13,8 @@ test_expect_success setup '
EOF
test_commit one &&
test_commit two &&
+ test_commit rebase-on-me &&
+ git reset --hard HEAD^ &&
test_commit three three
'
@@ -51,6 +53,24 @@ test_expect_success 'post-checkout receives the right args when not switching br
rm -f .git/post-checkout.args
'
+test_expect_success 'post-checkout is triggered on rebase' '
+ git checkout -b rebase-test master &&
+ rm -f .git/post-checkout.args &&
+ git rebase rebase-on-me &&
+ read old new flag < .git/post-checkout.args &&
+ test $old != $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
+'
+
+test_expect_success 'post-checkout is triggered on rebase with fast-forward' '
+ git checkout -b ff-rebase-test rebase-on-me^ &&
+ rm -f .git/post-checkout.args &&
+ git rebase rebase-on-me &&
+ read old new flag < .git/post-checkout.args &&
+ test $old != $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
+'
+
if test "$(git config --bool core.filemode)" = true; then
mkdir -p templates/hooks
write_script templates/hooks/post-checkout <<-\EOF
--
2.20.1
^ permalink raw reply related
* [PATCH 1/2] t5403: Refactor
From: orgads @ 2018-12-24 21:24 UTC (permalink / raw)
To: git; +Cc: Orgad Shaneh
In-Reply-To: <20181224212425.16596-1-orgads@gmail.com>
From: Orgad Shaneh <orgads@gmail.com>
* Replace multiple clones and commits by test_commits.
* Replace 3 invocations of awk by read.
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
t/t5403-post-checkout-hook.sh | 80 +++++++++++++----------------------
1 file changed, 29 insertions(+), 51 deletions(-)
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index fc898c9eac..9f9a5163c5 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -7,77 +7,55 @@ test_description='Test the post-checkout hook.'
. ./test-lib.sh
test_expect_success setup '
- echo Data for commit0. >a &&
- echo Data for commit0. >b &&
- git update-index --add a &&
- git update-index --add b &&
- tree0=$(git write-tree) &&
- commit0=$(echo setup | git commit-tree $tree0) &&
- git update-ref refs/heads/master $commit0 &&
- git clone ./. clone1 &&
- git clone ./. clone2 &&
- GIT_DIR=clone2/.git git branch new2 &&
- echo Data for commit1. >clone2/b &&
- GIT_DIR=clone2/.git git add clone2/b &&
- GIT_DIR=clone2/.git git commit -m new2
-'
-
-for clone in 1 2; do
- cat >clone${clone}/.git/hooks/post-checkout <<'EOF'
-#!/bin/sh
-echo $@ > $GIT_DIR/post-checkout.args
-EOF
- chmod u+x clone${clone}/.git/hooks/post-checkout
-done
-
-test_expect_success 'post-checkout runs as expected ' '
- GIT_DIR=clone1/.git git checkout master &&
- test -e clone1/.git/post-checkout.args
+ mv .git/hooks-disabled .git/hooks &&
+ write_script .git/hooks/post-checkout <<-\EOF &&
+ echo $@ >.git/post-checkout.args
+ EOF
+ test_commit one &&
+ test_commit two &&
+ test_commit three three
'
test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' '
- old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
- test $old = $new && test $flag = 1
+ git checkout master &&
+ test -e .git/post-checkout.args &&
+ read old new flag <.git/post-checkout.args &&
+ test $old = $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
'
test_expect_success 'post-checkout runs as expected ' '
- GIT_DIR=clone1/.git git checkout master &&
- test -e clone1/.git/post-checkout.args
+ git checkout master &&
+ test -e .git/post-checkout.args &&
+ rm -f .git/post-checkout.args
'
test_expect_success 'post-checkout args are correct with git checkout -b ' '
- GIT_DIR=clone1/.git git checkout -b new1 &&
- old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
- test $old = $new && test $flag = 1
+ git checkout -b new1 &&
+ read old new flag <.git/post-checkout.args &&
+ test $old = $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
'
test_expect_success 'post-checkout receives the right args with HEAD changed ' '
- GIT_DIR=clone2/.git git checkout new2 &&
- old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
- test $old != $new && test $flag = 1
+ git checkout two &&
+ read old new flag <.git/post-checkout.args &&
+ test $old != $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
'
test_expect_success 'post-checkout receives the right args when not switching branches ' '
- GIT_DIR=clone2/.git git checkout master b &&
- old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
- test $old = $new && test $flag = 0
+ git checkout master -- three &&
+ read old new flag <.git/post-checkout.args &&
+ test $old = $new && test $flag = 0 &&
+ rm -f .git/post-checkout.args
'
if test "$(git config --bool core.filemode)" = true; then
mkdir -p templates/hooks
-cat >templates/hooks/post-checkout <<'EOF'
-#!/bin/sh
-echo $@ > $GIT_DIR/post-checkout.args
+write_script templates/hooks/post-checkout <<-\EOF
+echo $@ >$GIT_DIR/post-checkout.args
EOF
-chmod +x templates/hooks/post-checkout
test_expect_success 'post-checkout hook is triggered by clone' '
git clone --template=templates . clone3 &&
--
2.20.1
^ permalink raw reply related
* [PATCH] Rebase: Run post-checkout hook on checkout
From: orgads @ 2018-12-24 21:24 UTC (permalink / raw)
To: git; +Cc: Orgad Shaneh
From: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
builtin/rebase.c | 11 +++++++++--
t/t5403-post-checkout-hook.sh | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b5c99ec10c..7f7a2c738e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -530,6 +530,7 @@ static int run_specific_rebase(struct rebase_options *opts)
#define RESET_HEAD_DETACH (1<<0)
#define RESET_HEAD_HARD (1<<1)
+#define RESET_HEAD_RUN_HOOK (1<<2)
static int reset_head(struct object_id *oid, const char *action,
const char *switch_to_branch, unsigned flags,
@@ -537,6 +538,7 @@ static int reset_head(struct object_id *oid, const char *action,
{
unsigned detach_head = flags & RESET_HEAD_DETACH;
unsigned reset_hard = flags & RESET_HEAD_HARD;
+ unsigned run_hook = flags & RESET_HEAD_RUN_HOOK;
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
@@ -636,6 +638,10 @@ static int reset_head(struct object_id *oid, const char *action,
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
UPDATE_REFS_MSG_ON_ERR);
}
+ if (run_hook)
+ run_hook_le(NULL, "post-checkout",
+ oid_to_hex(orig ? orig : &null_oid),
+ oid_to_hex(oid), "1", NULL);
leave_reset_head:
strbuf_release(&msg);
@@ -1465,7 +1471,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
options.switch_to);
if (reset_head(&oid, "checkout",
- options.head_name, 0,
+ options.head_name,
+ RESET_HEAD_RUN_HOOK,
NULL, buf.buf) < 0) {
ret = !!error(_("could not switch to "
"%s"),
@@ -1539,7 +1546,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
strbuf_addf(&msg, "%s: checkout %s",
getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
if (reset_head(&options.onto->object.oid, "checkout", NULL,
- RESET_HEAD_DETACH, NULL, msg.buf))
+ RESET_HEAD_DETACH | RESET_HEAD_RUN_HOOK, NULL, msg.buf))
die(_("Could not detach HEAD"));
strbuf_release(&msg);
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index 9f9a5163c5..5b4e582caa 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -13,6 +13,8 @@ test_expect_success setup '
EOF
test_commit one &&
test_commit two &&
+ test_commit rebase-on-me &&
+ git reset --hard HEAD^ &&
test_commit three three
'
@@ -51,6 +53,24 @@ test_expect_success 'post-checkout receives the right args when not switching br
rm -f .git/post-checkout.args
'
+test_expect_success 'post-checkout is triggered on rebase' '
+ git checkout -b rebase-test master &&
+ rm -f .git/post-checkout.args &&
+ git rebase rebase-on-me &&
+ read old new flag < .git/post-checkout.args &&
+ test $old != $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
+'
+
+test_expect_success 'post-checkout is triggered on rebase with fast-forward' '
+ git checkout -b ff-rebase-test rebase-on-me^ &&
+ rm -f .git/post-checkout.args &&
+ git rebase rebase-on-me &&
+ read old new flag < .git/post-checkout.args &&
+ test $old != $new && test $flag = 1 &&
+ rm -f .git/post-checkout.args
+'
+
if test "$(git config --bool core.filemode)" = true; then
mkdir -p templates/hooks
write_script templates/hooks/post-checkout <<-\EOF
--
2.20.1
^ permalink raw reply related
* Re: [PATCH 2/2] Rebase: Run post-checkout hook on checkout
From: Orgad Shaneh @ 2018-12-24 21:24 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <nycvar.QRO.7.76.6.1812211708010.41@tvgsbejvaqbjf.bet>
Hi Johannes,
On Fri, Dec 21, 2018 at 6:12 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Orgad,
>
> On Thu, 20 Dec 2018, orgads@gmail.com wrote:
>
> > From: Orgad Shaneh <orgads@gmail.com>
> >
> > Signed-off-by: Orgad Shaneh <orgads@gmail.com>
>
> Feel free to steal the PR description I added to your PR at
> https://github.com/git-for-windows/git/pull/1992
>
> > diff --git a/builtin/rebase.c b/builtin/rebase.c
> > index b5c99ec10c..78a09dcda2 100644
> > --- a/builtin/rebase.c
> > +++ b/builtin/rebase.c
> > @@ -530,6 +530,7 @@ static int run_specific_rebase(struct rebase_options *opts)
> >
> > #define RESET_HEAD_DETACH (1<<0)
> > #define RESET_HEAD_HARD (1<<1)
> > +#define RESET_HEAD_RUN_HOOK (1<<2)
> >
> > static int reset_head(struct object_id *oid, const char *action,
> > const char *switch_to_branch, unsigned flags,
> > @@ -537,6 +538,7 @@ static int reset_head(struct object_id *oid, const char *action,
> > {
> > unsigned detach_head = flags & RESET_HEAD_DETACH;
> > unsigned reset_hard = flags & RESET_HEAD_HARD;
> > + unsigned run_hook = flags & RESET_HEAD_RUN_HOOK;
> > struct object_id head_oid;
> > struct tree_desc desc[2] = { { NULL }, { NULL } };
> > struct lock_file lock = LOCK_INIT;
> > @@ -636,6 +638,10 @@ static int reset_head(struct object_id *oid, const char *action,
> > ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
> > UPDATE_REFS_MSG_ON_ERR);
> > }
> > + if (run_hook)
> > + run_hook_le(NULL, "post-checkout",
> > + oid_to_hex(orig ? orig : &null_oid),
> > + oid_to_hex(oid), "1", NULL);
>
> IIRC there was one `git checkout` in the scripted version that ran the
> hook, and one did not. The latter did not run it because it did not
> actually change the HEAD, but just switched branches.
>
> We could imitate that here by extending the `if (run_hook)` to `if
> (run_hook && !oideq(&head_oid, oid))`, I think. Do you agree?
Not exactly. That's what I thought, but it looks like I was wrong.
Returning to the branch is done in sequencer.c. The 2 calls to reset_head
happen on fast-forward case.
On fast-forward there is a call to reset_head with "checkout",
followed by a call
with "Fast-forwarded". I'm not sure what exactly it does, but on my test it sent
a null oid.
I did however miss the `switch-to` case, which I now added too.
- Orgad
^ permalink raw reply
* Re: [PATCH 1/2] t5403: Refactor
From: Orgad Shaneh @ 2018-12-24 20:54 UTC (permalink / raw)
To: git
In-Reply-To: <CAGHpTB+9L55Gvezhb7x6Kb49WS_nfzmKdVvpH3_=6GM7y8YQ_g@mail.gmail.com>
Hi Johannes,
Thanks for reviewing this.
On Fri, Dec 21, 2018 at 6:06 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Orgad,
>
> On Thu, 20 Dec 2018, orgads@gmail.com wrote:
>
> > diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
> > index fc898c9eac..7e941537f9 100755
> > --- a/t/t5403-post-checkout-hook.sh
> > +++ b/t/t5403-post-checkout-hook.sh
> > @@ -7,67 +7,48 @@ test_description='Test the post-checkout hook.'
> > . ./test-lib.sh
> >
> > test_expect_success setup '
> > - echo Data for commit0. >a &&
> > - echo Data for commit0. >b &&
> > - git update-index --add a &&
> > - git update-index --add b &&
> > - tree0=$(git write-tree) &&
> > - commit0=$(echo setup | git commit-tree $tree0) &&
> > - git update-ref refs/heads/master $commit0 &&
> > - git clone ./. clone1 &&
> > - git clone ./. clone2 &&
> > - GIT_DIR=clone2/.git git branch new2 &&
> > - echo Data for commit1. >clone2/b &&
> > - GIT_DIR=clone2/.git git add clone2/b &&
> > - GIT_DIR=clone2/.git git commit -m new2
> > + test_commit one &&
> > + test_commit two &&
> > + test_commit three three &&
>
> A very nice simplification (but please use tabs to indent).
Thanks. I already did. I sent these patches twice - first revision had
spaces, and the second one had tabs.
> > + mv .git/hooks-disabled .git/hooks
> > '
> >
> > -for clone in 1 2; do
> > - cat >clone${clone}/.git/hooks/post-checkout <<'EOF'
> > +cat >.git/hooks/post-checkout <<'EOF'
> > #!/bin/sh
> > -echo $@ > $GIT_DIR/post-checkout.args
> > +echo $@ > .git/post-checkout.args
>
> While at it, you could lose the space after the redirector that we seem to
> no longer prefer:
>
> > +echo $@ >.git/post-checkout.args
>
> And since we are already cleaning up, we could easily move use
> write_script instead, *and* move it into the `setup` test case (which
> makes it easier to use something like
>
> sh t5403-post-checkout-hook.sh --run=1,13
Done.
> The rest looks good (modulo indentation issues). I would have preferred
> the separate concerns to be addressed in individual commits (one commit to
> replace the `awk` calls, one to avoid the clones, one to simplify by using
> `test_commit`, etc), as that would have been easier to review. But others
> might disagree (Junio recently made the case of smooshing separate
> concerns into single commits, even squashing two of my patches into one
> against my wish), so... I guess you don't have to change this.
I also like commit granularity, but since I'm not familiar with the
workflow in the mailing list, how to amend and resend commits etc. I
try to keep the number of commits low :)
Thanks,
- Orgad
^ permalink raw reply
* Re: Unable to install latest git version. Claims git process pid running
From: Johannes Schindelin @ 2018-12-24 19:08 UTC (permalink / raw)
To: David Brown; +Cc: git
In-Reply-To: <7b41b16c39632660c48bffc90e171ab9@davidwbrown.name>
Hi David,
On Fri, 21 Dec 2018, David Brown wrote:
> Unfortunately I have hit refresh many times in previous attempts.
>
> Notwithstanding, the dialog maintains the error condition claiming pid 10128
> must be closed prior to install.
That must mean that there *is* a process with that ID. Have you tried
`wmic process list`?
Ciao,
Johannes
>
> I'm a big fan of Git but not a Windows fan in the least.
>
> I have downloaded the latest Windows git and killing as many apps and pids
> possible after Windows restart the installation goes south nonetheless.
>
> Please advise.
>
>
> On 2018-12-21 09:55, Johannes Schindelin wrote:
> > Hi,
> >
> > On Thu, 20 Dec 2018, David Brown wrote:
> >
> > > - [ ] I was not able to find an
> > > [open](https://github.com/git-for-windows/git/issues?q=is%3Aopen) or
> > > [closed](https://github.com/git-for-windows/git/issues?q=is%3Aclosed)
> > > issue
> > > matching what I'm seeing
> >
> > That's a new one. I saw many bug reporters simply deleting the issue
> > reporting template at https://github.com/git-for-windows/git/issues/new
> > (and usually then filing only very little information, definitely not
> > enough to make sense of the bug report), but I never saw this bug
> > reporting template being used to report a Git for Windows bug to the Git
> > mailing list yet ;-)
> >
> > > ### Setup
> > >
> > > - Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
> > >
> > > $ git --version --build-options
> > >
> > > git version 2.20.0.windows.1 cpu: x86_64 built from commit:
> > > 95155834166f64fe9666f2c0a4909f076080893a
> > > sizeof-long: 4
> > > sizeof-size_t: 8 **
> > >
> > > - Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit
> > > or
> > > 64-bit?
> > >
> > > $ cmd.exe /c ver
> > >
> > > ** Microsoft Windows [Version 6.1.7601] **
> > >
> > > - What options did you set as part of the installation? Or did you choose
> > > the
> > > defaults?
> > >
> > > # One of the following:
> > >
> > > $ cat /etc/install-options.txt Editor Option: VIM Custom Editor Path:
> > > Path Option: BashOnly
> > > SSH Option: OpenSSH
> > > CURL Option: WinSSL
> > > CRLF Option: CRLFAlways
> > > Bash Terminal Option: MinTTY
> > > Performance Tweaks
> > > FSCache: Enabled
> > > Use Credential Manager: Enabled
> > > Enable Symlinks: Disabled
> > >
> > > - Any other interesting things about your environment that might be
> > > related
> > > to the issue you're seeing?
> > >
> > > ** A so-called VDI running on a Dell WYSE **
> > >
> > > ### Details
> > >
> > > - Which terminal/shell are you running Git from? e.g
> > > Bash/CMD/PowerShell/other
> > >
> > > ** Bash **
> > >
> > > - What commands did you run to trigger this issue? If you can provide a
> > > [Minimal, Complete, and Verifiable
> > > example](http://stackoverflow.com/help/mcve)
> > > this will help us understand the issue.
> > >
> > > ** Windows git upgrade dialog **
> > >
> > > - What did you expect to occur after running these commands?
> > >
> > > ** latest version of git installed **
> > >
> > > - What actually happened instead?
> > >
> > > ** No such pid 10128 to close therefore cancel install **
> >
> > This typically means that that process existed *at the time the installer
> > checked*. If it was a short-lived process, you can check again by clicking
> > that "Refresh" button on the lower left.
> >
> > Ciao,
> > Johannes
> >
> > >
> > > - If the probleminsert URL herey, can you provide the
> > > URL to that repository to help us with testing?
> > >
> > > ** Internal company url. Windows git install dialog is issue **
> > >
>
>
^ permalink raw reply
* Re: [PATCH 1/1] abspath_part_inside_repo: respect core.fileMode
From: Johannes Schindelin @ 2018-12-24 18:54 UTC (permalink / raw)
To: Carlo Arenas; +Cc: Johannes Schindelin via GitGitGadget, git, Junio C Hamano
In-Reply-To: <CAPUEspjJSHfNtu8CyLjfRJ3JSzvP2WYcQ8f7Dp5L9vRaXvf0=g@mail.gmail.com>
Hi Carlo,
On Sat, 22 Dec 2018, Carlo Arenas wrote:
> On Fri, Dec 21, 2018 at 8:34 AM Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > +test_expect_success MINGW 'path is case-insensitive' '
>
> CASE_INSENSITIVE_FS might be a better prereq
You're right, the path that I downcase in the test contains an upper case
"BLUB" component.
Will fix,
Johannes
^ permalink raw reply
* Re: Parsing trailers
From: William Chargin @ 2018-12-24 18:52 UTC (permalink / raw)
To: Christian Couder; +Cc: Git Mailing List
In-Reply-To: <CAP8UFD1ErRo7NQmCrAJLaELzV-1rKowyPsNCi3ecTqGN1qWxKQ@mail.gmail.com>
Hi Christian: thanks for your reply.
> Changing the default separator as shown above, should make it easier
> to parse the result.
But this actually also changes which lines are considered trailers,
right? If the commit message ends with
Signed-off-by: one
Signed-off-by| two
and the user’s `trailer.separators` is set to `:`, then the correct
result should be only `Signed-off-by: one`. But when adding `|` as a
separator, we also see `Signed-off-by: two` in the result.
$ printf '.\n\nSigned-off-by: one\nSigned-off-by| two\n' |
> git interpret-trailers --parse
Signed-off-by: one
$ printf '.\n\nSigned-off-by: one\nSigned-off-by| two\n' |
> git -c trailer.separators='|:' interpret-trailers --parse
Signed-off-by| one
Signed-off-by| two
Best,
WC
^ permalink raw reply
* [PATCH v2 2/6] ref-filter: add check for negative file size
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <01020167e063687c-37a43a09-0a5f-4335-8c21-ec15a0a67882-000000@eu-west-1.amazonses.com>
If we have negative file size, we are doing something wrong.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
ref-filter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ref-filter.c b/ref-filter.c
index fd95547676047..45c558bcbd521 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1491,6 +1491,8 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
OBJECT_INFO_LOOKUP_REPLACE))
return strbuf_addf_ret(err, -1, _("missing object %s for %s"),
oid_to_hex(&oi->oid), ref->refname);
+ if (oi->info.disk_sizep && oi->disk_size < 0)
+ BUG("Object size is less than zero.");
if (oi->info.contentp) {
*obj = parse_object_buffer(the_repository, &oi->oid, oi->type, oi->size, oi->content, &eaten);
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 1/6] ref-filter: add objectsize:disk option
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <CAL21BmnmfxpMgbW_Yz9D=FVZk_AzWF0uyrNZeSGPCs63PH1oag@mail.gmail.com>
Add new formatting option objectsize:disk to know
exact size that object takes up on disk.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
ref-filter.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 5de616befe46e..fd95547676047 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -231,12 +231,18 @@ static int objecttype_atom_parser(const struct ref_format *format, struct used_a
static int objectsize_atom_parser(const struct ref_format *format, struct used_atom *atom,
const char *arg, struct strbuf *err)
{
- if (arg)
- return strbuf_addf_ret(err, -1, _("%%(objectsize) does not take arguments"));
- if (*atom->name == '*')
- oi_deref.info.sizep = &oi_deref.size;
- else
- oi.info.sizep = &oi.size;
+ if (!arg) {
+ if (*atom->name == '*')
+ oi_deref.info.sizep = &oi_deref.size;
+ else
+ oi.info.sizep = &oi.size;
+ } else if (!strcmp(arg, "disk")) {
+ if (*atom->name == '*')
+ oi_deref.info.disk_sizep = &oi_deref.disk_size;
+ else
+ oi.info.disk_sizep = &oi.disk_size;
+ } else
+ return strbuf_addf_ret(err, -1, _("unrecognized %%(objectsize) argument: %s"), arg);
return 0;
}
@@ -880,7 +886,10 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
name++;
if (!strcmp(name, "objecttype"))
v->s = xstrdup(type_name(oi->type));
- else if (!strcmp(name, "objectsize")) {
+ else if (!strcmp(name, "objectsize:disk")) {
+ v->value = oi->disk_size;
+ v->s = xstrfmt("%"PRIuMAX, (intmax_t)oi->disk_size);
+ } else if (!strcmp(name, "objectsize")) {
v->value = oi->size;
v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size);
}
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 5/6] ref-filter: add tests for deltabase
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <01020167e063687c-37a43a09-0a5f-4335-8c21-ec15a0a67882-000000@eu-west-1.amazonses.com>
Test new formatting option deltabase.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
t/t6300-for-each-ref.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 097fdf21fe196..0ffd63071392e 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -84,6 +84,7 @@ test_atom head push:strip=-1 master
test_atom head objecttype commit
test_atom head objectsize 171
test_atom head objectsize:disk 138
+test_atom head deltabase 0000000000000000000000000000000000000000
test_atom head objectname $(git rev-parse refs/heads/master)
test_atom head objectname:short $(git rev-parse --short refs/heads/master)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -127,6 +128,8 @@ test_atom tag objecttype tag
test_atom tag objectsize 154
test_atom tag objectsize:disk 138
test_atom tag '*objectsize:disk' 138
+test_atom tag deltabase 0000000000000000000000000000000000000000
+test_atom tag '*deltabase' 0000000000000000000000000000000000000000
test_atom tag objectname $(git rev-parse refs/tags/testtag)
test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 3/6] ref-filter: add tests for objectsize:disk
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <01020167e063687c-37a43a09-0a5f-4335-8c21-ec15a0a67882-000000@eu-west-1.amazonses.com>
Test new formatting atom.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
t/t6300-for-each-ref.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 97bfbee6e8d69..097fdf21fe196 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -83,6 +83,7 @@ test_atom head push:strip=1 remotes/myfork/master
test_atom head push:strip=-1 master
test_atom head objecttype commit
test_atom head objectsize 171
+test_atom head objectsize:disk 138
test_atom head objectname $(git rev-parse refs/heads/master)
test_atom head objectname:short $(git rev-parse --short refs/heads/master)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -124,6 +125,8 @@ test_atom tag upstream ''
test_atom tag push ''
test_atom tag objecttype tag
test_atom tag objectsize 154
+test_atom tag objectsize:disk 138
+test_atom tag '*objectsize:disk' 138
test_atom tag objectname $(git rev-parse refs/tags/testtag)
test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 4/6] ref-filter: add deltabase option
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <01020167e063687c-37a43a09-0a5f-4335-8c21-ec15a0a67882-000000@eu-west-1.amazonses.com>
Add new formatting option: deltabase.
If the object is stored as a delta on-disk, this expands
to the 40-hex sha1 of the delta base object.
Otherwise, expands to the null sha1 (40 zeroes).
We have same option in cat-file command.
Hopefully, in the end I will remove formatting code from
cat-file and reuse formatting parts from ref-filter.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
ref-filter.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/ref-filter.c b/ref-filter.c
index 45c558bcbd521..debb8cacad067 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -246,6 +246,18 @@ static int objectsize_atom_parser(const struct ref_format *format, struct used_a
return 0;
}
+static int deltabase_atom_parser(const struct ref_format *format, struct used_atom *atom,
+ const char *arg, struct strbuf *err)
+{
+ if (arg)
+ return strbuf_addf_ret(err, -1, _("%%(deltabase) does not take arguments"));
+ if (*atom->name == '*')
+ oi_deref.info.delta_base_sha1 = oi_deref.delta_base_oid.hash;
+ else
+ oi.info.delta_base_sha1 = oi.delta_base_oid.hash;
+ return 0;
+}
+
static int body_atom_parser(const struct ref_format *format, struct used_atom *atom,
const char *arg, struct strbuf *err)
{
@@ -437,6 +449,7 @@ static struct {
{ "objecttype", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },
{ "objectsize", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },
{ "objectname", SOURCE_OTHER, FIELD_STR, objectname_atom_parser },
+ { "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
{ "tree", SOURCE_OBJ },
{ "parent", SOURCE_OBJ },
{ "numparent", SOURCE_OBJ, FIELD_ULONG },
@@ -892,7 +905,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
} else if (!strcmp(name, "objectsize")) {
v->value = oi->size;
v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size);
- }
+ } else if (!strcmp(name, "deltabase"))
+ v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
else if (deref)
grab_objectname(name, &oi->oid, v, &used_atom[i]);
}
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 6/6] ref-filter: add docs for new options
From: Olga Telezhnaya @ 2018-12-24 13:24 UTC (permalink / raw)
To: git
In-Reply-To: <01020167e063687c-37a43a09-0a5f-4335-8c21-ec15a0a67882-000000@eu-west-1.amazonses.com>
Add documentation for formatting options objectsize:disk
and deltabase.
Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
Documentation/git-for-each-ref.txt | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index 901faef1bfdce..774cecc7ede78 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -128,13 +128,18 @@ objecttype::
objectsize::
The size of the object (the same as 'git cat-file -s' reports).
-
+ Append `:disk` to get the size, in bytes, that the object takes up on
+ disk. See the note about on-disk sizes in the `CAVEATS` section below.
objectname::
The object name (aka SHA-1).
For a non-ambiguous abbreviation of the object name append `:short`.
For an abbreviation of the object name with desired length append
`:short=<length>`, where the minimum length is MINIMUM_ABBREV. The
length may be exceeded to ensure unique object names.
+deltabase::
+ This expands to the object name of the delta base for the
+ given object, if it is stored as a delta. Otherwise it
+ expands to the null object name (all zeroes).
upstream::
The name of a local ref which can be considered ``upstream''
@@ -361,6 +366,20 @@ This prints the authorname, if present.
git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Authored by: %(authorname)%(end)"
------------
+CAVEATS
+-------
+
+Note that the sizes of objects on disk are reported accurately, but care
+should be taken in drawing conclusions about which refs or objects are
+responsible for disk usage. The size of a packed non-delta object may be
+much larger than the size of objects which delta against it, but the
+choice of which object is the base and which is the delta is arbitrary
+and is subject to change during a repack.
+
+Note also that multiple copies of an object may be present in the object
+database; in this case, it is undefined which copy's size or delta base
+will be reported.
+
SEE ALSO
--------
linkgit:git-show-ref[1]
--
https://github.com/git/git/pull/552
^ permalink raw reply related
* [PATCH v2 0/5] ref-filter: add new formatting options
From: Оля Тележная @ 2018-12-24 13:16 UTC (permalink / raw)
To: git, Christian Couder, Jeff King
In-Reply-To: <CAL21BmnoZuRih3Ky66_Tk0PweD36eZ6=fbY3jGumRcSJ=Bc_pQ@mail.gmail.com>
пт, 9 нояб. 2018 г. в 10:37, Оля Тележная <olyatelezhnaya@gmail.com>:
>
> Add formatting options %(objectsize:disk) and %(deltabase), as in
> cat-file command.
>
> I can not test %(deltabase) properly (I mean, I want to have test with
> meaningful deltabase in the result - now we have only with zeros). I
> tested it manually on my git repo, and I have not-null deltabases
> there. We have "t/t1006-cat-file.sh" with similar case, but it is
> about blobs. ref-filter does not work with blobs, I need to write test
> about refs, and I feel that I can't catch the idea (and it is hard for
> me to write in Shell).
>
> Finally, I want to remove formatting logic in cat-file and use
> functions from ref-filter (we are almost there, so many work was done
> for this). I had an idea to make this migration in this patch (and
> stop worrying about bad tests about deltabase: we already have such
> test for cat-file and hopefully that could be enough). But I have
> another question there. cat-file has one more formatting option:
> "rest" [1]. Do we want such formatting option in ref-filter? It's
> easier for me to support that in ref-filter than to leave it only
> specifically for cat-file.
Updates since previous version:
1. Fix type cast not to generate warnings/errors in other system
platforms (travis CI says that everything is OK now)
2. Add check for negative object size (BUG if it is negative)
3. Update documentation (thanks to Junio for better wording)
>
> Thank you!
>
> [1] https://git-scm.com/docs/git-cat-file#git-cat-file-coderestcode
^ permalink raw reply
* Re: Parsing trailers
From: Christian Couder @ 2018-12-24 10:58 UTC (permalink / raw)
To: William Chargin; +Cc: Git Mailing List
In-Reply-To: <CAFW+GMDazFSDzBrvzMqaPGwew=+CP7tw7G5FfDqcAUYd3qjPuQ@mail.gmail.com>
On Sun, Dec 23, 2018 at 11:44 PM William Chargin <wchargin@gmail.com> wrote:
>
> I'm interested in parsing the output of `git-interpret-trailers` in a
> script. I had hoped that the `--parse` option would make this easy, but
> it seems that the `trailer.separators` configuration option is used to
> specify both the input format (which separators may indicate a trailer)
> and the output format of `git interpret-trailers --parse`.
Yeah, but it can take many characters, not just one.
For example you might want to do something like:
seps=$(git config trailer.separators)
test -z "$seps" && seps=':'
git -c trailer.separators="|$seps" interpret-trailers --parse infile >outfile
So that the output uses '|' as a separator.
> Given that
> `trailer.separators` may contain any (non-NUL) characters, including
> whitespace, parsing the output is not straightforward.
Changing the default separator as shown above, should make it easier
to parse the result.
^ permalink raw reply
* [PATCH v4 3/3] branch: Add an extra verbose output displaying worktree path for refs checked out in a linked worktree
From: nbelakovski @ 2018-12-24 8:47 UTC (permalink / raw)
To: git; +Cc: peff, rafa.almas, gitster, avarab, Nickolai Belakovski
In-Reply-To: <20181224084756.49952-1-nbelakovski@gmail.com>
From: Nickolai Belakovski <nbelakovski@gmail.com>
---
builtin/branch.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/builtin/branch.c b/builtin/branch.c
index 2a24153b78..56589a3684 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -366,6 +366,10 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
strbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));
strbuf_addf(&local, " %s ", obname.buf);
+ if (filter->verbose > 2)
+ strbuf_addf(&local, "%s%%(if:notequals=*)%%(HEAD)%%(then)%%(if)%%(worktreepath)%%(then)%%(worktreepath) %%(end)%%(end)%s",
+ branch_get_color(BRANCH_COLOR_WORKTREE), branch_get_color(BRANCH_COLOR_RESET));
+
if (filter->verbose > 1)
strbuf_addf(&local, "%%(if)%%(upstream)%%(then)[%s%%(upstream:short)%s%%(if)%%(upstream:track)"
"%%(then): %%(upstream:track,nobracket)%%(end)] %%(end)%%(contents:subject)",
--
2.14.2
^ permalink raw reply related
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