git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Strain, Roger L." <roger.strain@swri.org>
To: "emaste@freebsd.org" <emaste@freebsd.org>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	"marc@msys.ch" <marc@msys.ch>
Subject: Re: Regression in git-subtree.sh, introduced in 2.20.1, after 315a84f9aa0e2e629b0680068646b0032518ebed
Date: Mon, 9 Dec 2019 16:19:09 +0000	[thread overview]
Message-ID: <1c62a65d7effb49c6bd258f462f34221ac1c7ff1.camel@swri.org> (raw)
In-Reply-To: <CAPyFy2BjWx2Hp+H__kDFRFZZjcK4hc99oKqkZQjXPLfQE=2SPg@mail.gmail.com>

So it's been quite a while since I made this specific change, but I'll
attach the relevant portion of the diff below. I may be completely
misremembering portions, and apologize in advance. This was based on an
earlier version of the script, and I can see some other changes have
been made since I forked, but perhaps this will still explain what I
tried to do to work around our problem.

Within process_split_commit, there's logic that tries to distinguish
between commits which are mainline and commits which are subtree.
There's even a comment in the relevant section asking "Is there no
better way? Does it matter?" Well, the answer was yes, it mattered,
because we were picking up mainline commits that there before the
initial add of a subtree, and those were getting sucked in as if they
were subtree commits, and then all the remaining hashes were off.

What this change was meant to do was to check for the existence of a
single, known file. We keep a file called "subtrees.csv" in the root of
our mainline repo, and it defines the various subtrees that comprise
the mainline. Therefore, if that file exists, I can say with certainty
that it is a mainline commit. So when that dodgy check comes up, it
checks for the file first, then falls back to the old behavior.

Partial diff follows, feel free to try it out if it sounds like a
similar problem that you're facing. Change the specific filename for
your needs, obviously.

To be clear, this is NOT something I'm submitting for inclusion in the
general release; it's very repo-specific, and I just hope it might help
a fellow soul.

@@ -506,6 +499,20 @@ subtree_for_commit () {
        done
 }
 
+subtree_for_csv () {
+       commit="$1"
+       dir="$2"
+       git ls-tree "$commit" -- "$dir" |
+       while read mode type tree name
+       do
+               assert test "$name" = "$dir"
+               assert test "$type" = "blob" -o "$type" = "commit"
+               test "$type" = "commit" && continue  # ignore
submodules
+               echo $tree
+               break
+       done
+}
+
 tree_changed () {
        tree=$1
        shift
@@ -667,9 +674,17 @@ process_split_commit () {
        if test -z "$tree"
        then
                set_notree "$rev"
-               if test -n "$newparents"
+               subtreescsv=$(subtree_for_csv "$rev" "subtrees.csv")
+               debug "${indentprefix}  subtrees.csv tree is:
$subtreescsv"
+
+               # ugly.  is there no better way to tell if this is a
subtree
+               # vs. a mainline commit?  Does it matter?
+               if test -z "$subtreescsv"
                then
-                       cache_set "$rev" "$rev"
+                       if test -n "$newparents"
+                       then
+                               cache_set "$rev" "$rev"
+                       fi
                fi
                return
        fi


-- 
Roger Strain

-----Original Message-----
From: Ed Maste <emaste@freebsd.org>
To: "Strain, Roger L." <roger.strain@swri.org>
Cc: git@vger.kernel.org <git@vger.kernel.org>, marc@msys.ch <
marc@msys.ch>
Subject: Re: Regression in git-subtree.sh, introduced in 2.20.1, after
315a84f9aa0e2e629b0680068646b0032518ebed
Date: Mon, 09 Dec 2019 06:45:57 -0500

[EXTERNAL EMAIL]

On Mon, 9 Dec 2019 at 09:29, Strain, Roger L. <roger.strain@swri.org>
wrote:

I've had to further
customize the script for our internal use, and those changes aren't
something that would be useful for the public at large.

Would you describe the sort of problem you have to work around with
custom changes?

I'm starting on a path of trying to fix git-subtree for failures[1]
encountered in a prototype conversion of the FreeBSD repository from
svn to git. The misbehaviour I encounter occurs when split encounters
a commit for which the path being split is empty in 'git ls-tree', and
the commit is actually not a subtree commit. I'm currently
experimenting with hacks to skip specific hashes during the initial
subtree split. On reading your mail I realize I could address my issue
by testing for the existence of a specific file though, which makes me
wonder if the issue you have is similar.

[1] 
https://lore.kernel.org/git/CAPyFy2AsmaxU-BDf_teZJE5hiaVpTSZc8fftnuXPb_4-j7j5Fw@mail.gmail.com/



  reply	other threads:[~2019-12-09 16:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-08 10:30 Regression in git-subtree.sh, introduced in 2.20.1, after 315a84f9aa0e2e629b0680068646b0032518ebed Nadav SInai
2019-12-09 14:11 ` Strain, Roger L.
2019-12-09 11:45   ` Ed Maste
2019-12-09 16:19     ` Strain, Roger L. [this message]
2019-12-09 14:13   ` Marc Balmer
2019-12-09 14:18     ` Strain, Roger L.
2019-12-09 14:30       ` Marc Balmer
2019-12-09 15:26         ` Johannes Schindelin
2019-12-09 15:31           ` Marc Balmer
2019-12-09 19:38             ` Johannes Schindelin
2019-12-11  5:43               ` Tom Clarkson
2019-12-11 14:39                 ` Strain, Roger L.
2019-12-12  5:02                   ` Tom Clarkson
2019-12-13 13:41                     ` Johannes Schindelin
2019-12-14  8:29                       ` Marc Balmer
     [not found]                         ` <BAB4CF6D-6904-4698-ACE1-EBEEC745E569@msys.ch>
2019-12-14 14:27                           ` Tom Clarkson
2019-12-16 11:30                             ` Ed Maste
2019-12-18  0:15                               ` Tom Clarkson
2020-03-12 10:40                           ` Marc Balmer
2019-12-16  3:50                     ` Tom Clarkson
     [not found] <3E84DE22-9614-4E1B-9717-69F6777DD219@msys.ch>
2020-03-12 10:43 ` Tom Clarkson
  -- strict thread matches above, loose matches on Subject: below --
2018-12-31 10:28 Marc Balmer
2018-12-31 10:51 ` Duy Nguyen
2018-12-31 11:12   ` Marc Balmer
2018-12-31 11:20     ` Duy Nguyen
2018-12-31 11:24       ` Marc Balmer
2018-12-31 11:36         ` Duy Nguyen
2018-12-31 12:31           ` Marc Balmer
2019-01-01 13:19             ` Duy Nguyen
2019-01-02  9:13               ` Marc Balmer
2019-01-02 20:20         ` Strain, Roger L.
2019-01-03 13:50           ` Johannes Schindelin
2019-01-03 15:30             ` Strain, Roger L.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c62a65d7effb49c6bd258f462f34221ac1c7ff1.camel@swri.org \
    --to=roger.strain@swri.org \
    --cc=emaste@freebsd.org \
    --cc=git@vger.kernel.org \
    --cc=marc@msys.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).