git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-subtree: compare file names by absolute paths
@ 2016-08-12 15:49 Ivan Oleynikov
  2016-08-12 17:47 ` Ivan Oleynikov
  2016-08-12 18:30 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Ivan Oleynikov @ 2016-08-12 15:49 UTC (permalink / raw)
  To: git; +Cc: dvh, apenwarr

This commit removes false positive assertion fails of `git subtree split` when
the --prefix argument is not in a particular form produced by `git ls-tree`.

For example, typical usage of the command could be:

  git subtree split -b split --prefix=some/relative/path

But

  git subtree split -b split --prefix=./some/relative/path

Would fail with multiple assertion errors. This commit makes the latter command
work without errors.

Signed-off-by: Ivan Oleynikov <io@metrotek.spb.ru>
---

Notes:
    The bug fixed by this commit can be reproduced like this:
    
    $ git init
    Initialized empty Git repository in /tmp/test/.git/
    $ mkdir a b
    $ touch a/file b/file
    $ git add a
    $ git commit -m a
    [master (root-commit) b42584a] a
     1 file changed, 0 insertions($), 0 deletions(-)
     create mode 100644 a/file
    $ git add b
    $ git commit -m b
    [master 5114301] b
     1 file changed, 0 insertions($), 0 deletions(-)
     create mode 100644 b/file
    $ git subtree split -b split_a --prefix=a
    Created branch 'split_a'
    e9f5d81efacb33ab6cf67fe9ff376b33a483a92f
    $ git subtree split -b split_b --prefix=./b
    assertion failed:  [ b = ./b ]
    No new revisions were found
    
    When the commit is applied `git subtree split` works as expected:
    
    $ git init
    Initialized empty Git repository in /tmp/test/.git/
    $ mkdir a b
    $ touch a/file b/file
    $ git add a
    $ git commit -m a
    [master (root-commit) bc80f36] a
     1 file changed, 0 insertions($), 0 deletions(-)
     create mode 100644 a/file
    $ git add b
    $ git commit -m b
    [master e59c446] b
     1 file changed, 0 insertions($), 0 deletions(-)
     create mode 100644 b/file
    $ git subtree split -b split_a --prefix=a
    Created branch 'split_a'
    d542e9cd2de5956dd7ca77b169dba1c8418fa03a
    $ git subtree split -b split_b --prefix=./b
    Created branch 'split_b'
    3ae7854c0c395413c807b2bc4e75b651adc63f8c

 contrib/subtree/git-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index b567eae..d9351b9 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -411,7 +411,7 @@ subtree_for_commit()
 	dir="$2"
 	git ls-tree "$commit" -- "$dir" |
 	while read mode type tree name; do
-		assert [ "$name" = "$dir" ]
+		assert [ "$(readlink -f $name)" = "$(readlink -f $dir)" ]
 		assert [ "$type" = "tree" -o "$type" = "commit" ]
 		[ "$type" = "commit" ] && continue  # ignore submodules
 		echo $tree
-- 
2.1.4


-- 
Ivan Oleynikov
STC Metrotek
St.Petersburg

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-subtree: compare file names by absolute paths
  2016-08-12 15:49 [PATCH] git-subtree: compare file names by absolute paths Ivan Oleynikov
@ 2016-08-12 17:47 ` Ivan Oleynikov
  2016-08-12 18:30 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Ivan Oleynikov @ 2016-08-12 17:47 UTC (permalink / raw)
  To: git; +Cc: apenwarr

quote on Fri, Aug 12, 2016 at 06:49:42PM +0300 (Ivan Oleynikov):

BTW, this patch should be applied to `maint` branch. The similar change also
works if applied to master (patch for master must be a bit different).

-- 
Ivan Oleynikov
STC Metrotek
St.Petersburg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-subtree: compare file names by absolute paths
  2016-08-12 15:49 [PATCH] git-subtree: compare file names by absolute paths Ivan Oleynikov
  2016-08-12 17:47 ` Ivan Oleynikov
@ 2016-08-12 18:30 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2016-08-12 18:30 UTC (permalink / raw)
  To: Ivan Oleynikov, David A. Greene; +Cc: git, dvh, apenwarr

Ivan Oleynikov <io@metrotek.spb.ru> writes:

> Cc: git@vger.kernel.org,  dvh@metrotek.spb.ru,  apenwarr@gmail.com

I think Avery no longer actively works on this script; Dave Greene
has been helping it move forward by reviewing, so let's ask him to
lend his eyes.

> This commit removes false positive assertion fails of `git subtree split` when
> the --prefix argument is not in a particular form produced by `git ls-tree`.
>
> For example, typical usage of the command could be:
>
>   git subtree split -b split --prefix=some/relative/path
>
> But
>
>   git subtree split -b split --prefix=./some/relative/path
>
> Would fail with multiple assertion errors. This commit makes the latter command
> work without errors.
>
> Signed-off-by: Ivan Oleynikov <io@metrotek.spb.ru>
> ---
>
> Notes:
>     The bug fixed by this commit can be reproduced like this:
>     
>     $ git init
>     Initialized empty Git repository in /tmp/test/.git/
>     $ mkdir a b
>     $ touch a/file b/file
>     $ git add a
>     $ git commit -m a
>     [master (root-commit) b42584a] a
>      1 file changed, 0 insertions($), 0 deletions(-)
>      create mode 100644 a/file
>     $ git add b
>     $ git commit -m b
>     [master 5114301] b
>      1 file changed, 0 insertions($), 0 deletions(-)
>      create mode 100644 b/file
>     $ git subtree split -b split_a --prefix=a
>     Created branch 'split_a'
>     e9f5d81efacb33ab6cf67fe9ff376b33a483a92f
>     $ git subtree split -b split_b --prefix=./b
>     assertion failed:  [ b = ./b ]
>     No new revisions were found
>     
>     When the commit is applied `git subtree split` works as expected:
>     
>     $ git init
>     Initialized empty Git repository in /tmp/test/.git/
>     $ mkdir a b
>     $ touch a/file b/file
>     $ git add a
>     $ git commit -m a
>     [master (root-commit) bc80f36] a
>      1 file changed, 0 insertions($), 0 deletions(-)
>      create mode 100644 a/file
>     $ git add b
>     $ git commit -m b
>     [master e59c446] b
>      1 file changed, 0 insertions($), 0 deletions(-)
>      create mode 100644 b/file
>     $ git subtree split -b split_a --prefix=a
>     Created branch 'split_a'
>     d542e9cd2de5956dd7ca77b169dba1c8418fa03a
>     $ git subtree split -b split_b --prefix=./b
>     Created branch 'split_b'
>     3ae7854c0c395413c807b2bc4e75b651adc63f8c
>
>  contrib/subtree/git-subtree.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index b567eae..d9351b9 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -411,7 +411,7 @@ subtree_for_commit()
>  	dir="$2"
>  	git ls-tree "$commit" -- "$dir" |
>  	while read mode type tree name; do
> -		assert [ "$name" = "$dir" ]
> +		assert [ "$(readlink -f $name)" = "$(readlink -f $dir)" ]
>  		assert [ "$type" = "tree" -o "$type" = "commit" ]
>  		[ "$type" = "commit" ] && continue  # ignore submodules
>  		echo $tree
> -- 
> 2.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-12 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12 15:49 [PATCH] git-subtree: compare file names by absolute paths Ivan Oleynikov
2016-08-12 17:47 ` Ivan Oleynikov
2016-08-12 18:30 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).