git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: David Turner <dturner@twopensource.com>,
	git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH v6 25/25] refs: break out ref conflict checks
Date: Fri, 06 Nov 2015 15:24:18 -0800	[thread overview]
Message-ID: <xmqqd1vm3e59.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqq611f3umt.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Fri, 06 Nov 2015 09:28:10 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Michael Haggerty <mhagger@alum.mit.edu> writes:
>
>> Junio, if there are no more comments, would you mind
>>
>>     s/verify_no_descendants/find_descendant_ref/
>>
>> in the log message of this commit? And then, if you are also OK with the
>> new subdirectory introduced in this patch series, David and I seem to be
>> in agreement that it is ready to go. It would be great if this patch
>> series could be merged in a timely manner, as it will conflict with
>> nearly any other changes that people might want to undertake in the refs
>> code.
>
> Thanks for working well together.  Let me see what I can do today...

What I'll push out later today merges this to the tip of 'pu'.
The resolution is the same for 'jch' or 'next' (I checked).

I have to say that the merge of this topioc is not pretty.  A topic
that is already in flight has changed ref_is_hidden() in refs.c; you
move this block of code first to refs/refs-backend.c and then to
refs/refs.c, and the recursive merge ends up saying "The trunk side
changed this block of code in refs/refs-backend.c while the side
branch removed that block".

The resolution has to become an evil merge that brings in a new file
refs/refs.c from the tip of your topic to the trunk while replaying
that change in the lost block to that new file.  Because an
in-flight topic like this one needs to be merged over and over until
it gets merged to 'master' I'd prepare an evil merge-fix to be
squashed into the result of an auto-merge to help this process for
the interim maintainer, but this topic is placing more burden than
it otherwise would to the entire process.

Incidentally, that was why I originally asked you if you want to be
an interim maintainer for this cycle.  Whoever is doing a large code
movement with a large patch series must be the one who would know
the best how its interaction with other topics is best managed.

I wonder if refs.c -> refs/refs.c rename is a good idea.  I do agree
that refs/ subdirectory that collects the backend implementation
details is a very sensible thing to do, but if the public and
generic API were left in refs.c, this particular conflict might have
been less severe and easier to handle.  Whatever.

For those who are listening in from sideline, in case when they need
to deal with a similar situation "the code our side changed gets
moved to elsewhere by a side branch", here is what I did:

 * let "git merge --conflict=diff3" attempt and fail.

 * a conflicted file will have something like this:

    <<<< ours
    ... the code with changes made by our side (trunk) ...
    |||| base
    ... the code before our side (trunk) made the above changes ...
    ====
    >>>> theirs

 * create two new files, OURS and BASE.  Save the part in that
   conflicted file between <<<< and |||| to OURS, and between ||||
   and ==== to BASE.

 * look at "diff -u BASE OURS", find in the (failed) automerge
   result where the original went (a sample of it is at the end of
   this message), and apply that change manually.

The above is only to resolve this conflict *once*.

Automating future merges of this branch into a slightly updated
codebase needs help from rerere and also merge-fix/ machinery (this
is not in core-git proper, but the tool is in the 'todo' branch and
its use is described in howto/maintain-git.txt).

Essentially the procedure were:

 * "git checkout pu^0"

 * let "git merge --conflict=diff3" attempt and fail.

 * accept removal of the conflicted block in refs/files-backend.c in
   the editor, do "git rerere" to record it.  commit the result.

 * apply the above diff between BASE and OURS, commit the result.

 * git update-ref refs/merge-fix/dt/refs-backend-pre-vtable HEAD

With this, the Reintegrate script (on 'todo', checked out in "Meta/"
subdirectory) will be able to reproduce the evil merge, e.g.

 $ git checkout pu
 $ echo dt/refs-backend-pre-vtable | Meta/Reintegrate

would first let "git rerere" replay the removal of conflicted block
in refs/files-backend.c and then amend the result by squashing the
change in merge-fix/dt/refs-backend-pre-vtable.


--- V_BASE	2015-11-06 14:51:10.150197900 -0800
+++ V_OURS	2015-11-06 14:51:05.638059250 -0800
@@ -117,7 +117,7 @@
 	return 0;
 }
 
-int ref_is_hidden(const char *refname)
+int ref_is_hidden(const char *refname, const char *refname_full)
 {
 	int i;
 
@@ -125,6 +125,7 @@
 		return 0;
 	for (i = hide_refs->nr - 1; i >= 0; i--) {
 		const char *match = hide_refs->items[i].string;
+		const char *subject;
 		int neg = 0;
 		int len;
 
@@ -133,10 +134,18 @@
 			match++;
 		}
 
-		if (!starts_with(refname, match))
+		if (*match == '^') {
+			subject = refname_full;
+			match++;
+		} else {
+			subject = refname;
+		}
+
+		/* refname can be NULL when namespaces are used. */
+		if (!subject || !starts_with(subject, match))
 			continue;
 		len = strlen(match);
-		if (!refname[len] || refname[len] == '/')
+		if (!subject[len] || subject[len] == '/')
 			return !neg;
 	}
 	return 0;

  reply	other threads:[~2015-11-06 23:24 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28  2:14 [PATCH v5 00/26] refs backend pre-vtable David Turner
2015-10-28  2:14 ` [PATCH v5 01/26] refs.c: create a public version of verify_refname_available David Turner
2015-10-28  2:14 ` [PATCH v5 02/26] refs: make is_branch public David Turner
2015-10-28  2:14 ` [PATCH v5 03/26] refs-be-files.c: rename refs to refs-be-files David Turner
2015-10-28  2:14 ` [PATCH v5 04/26] refs.c: add a new refs.c file to hold all common refs code David Turner
2015-10-28  2:14 ` [PATCH v5 05/26] refs.c: move update_ref to refs.c David Turner
2015-10-28  2:14 ` [PATCH v5 06/26] refs.c: move delete_pseudoref and delete_ref to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 07/26] refs.c: move read_ref_at to the common refs file David Turner
2015-10-28  2:14 ` [PATCH v5 08/26] refs.c: move the hidden refs functions to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 09/26] refs.c: move dwim and friend functions to the common refs code David Turner
2015-10-28  2:14 ` [PATCH v5 10/26] refs.c: move warn_if_dangling_symref* to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 11/26] refs.c: move read_ref, read_ref_full and ref_exists " David Turner
2015-10-28  2:14 ` [PATCH v5 12/26] refs.c: move resolve_refdup to common David Turner
2015-10-28  2:14 ` [PATCH v5 13/26] refs.c: move check_refname_format to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 14/26] refs.c: move is_branch " David Turner
2015-10-28  2:14 ` [PATCH v5 15/26] refs.c: move prettify_refname " David Turner
2015-10-28  2:14 ` [PATCH v5 16/26] refs.c: move ref iterators " David Turner
2015-11-01  4:39   ` Michael Haggerty
2015-10-28  2:14 ` [PATCH v5 17/26] refs.c: move head_ref_namespaced " David Turner
2015-10-28  2:14 ` [PATCH v5 18/26] refs: move transaction functions into " David Turner
2015-11-01  8:17   ` Michael Haggerty
2015-11-02 22:19     ` David Turner
2015-10-28  2:14 ` [PATCH v5 19/26] refs.c: move refname_is_safe to the " David Turner
2015-10-28  2:14 ` [PATCH v5 20/26] refs.c: move copy_msg " David Turner
2015-10-28  2:14 ` [PATCH v5 21/26] refs.c: move peel_object " David Turner
2015-10-28  2:14 ` [PATCH v5 22/26] refs.c: move should_autocreate_reflog to " David Turner
2015-10-28  2:14 ` [PATCH v5 23/26] initdb: move safe_create_dir into " David Turner
2015-10-28  2:14 ` [PATCH v5 24/26] refs: make files_log_ref_write functions public David Turner
2015-10-28  2:14 ` [PATCH v5 25/26] refs: break out ref conflict checks David Turner
2015-11-02 16:52   ` Michael Haggerty
2015-10-28  2:14 ` [PATCH v5 26/26] introduce "extensions" form of core.repositoryformatversion David Turner
2015-11-03  7:36 ` [PATCH v5 00/26] refs backend pre-vtable Michael Haggerty
2015-11-03  7:39 ` [PATCH v6 00/25] " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 01/25] refs: make is_branch public Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 02/25] refs/files-backend.c: new file, renamed from refs.c Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 03/25] refs: add a new file, refs/refs.c, to hold common refs code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 04/25] refs: move update_ref to refs/refs.c Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 05/25] refs: move delete_pseudoref and delete_ref to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 06/25] refs: move read_ref_at to the common refs file Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 07/25] refs: move the hidden refs functions to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 08/25] refs: move dwim and friend functions to the common refs code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 09/25] refs: move warn_if_dangling_symref* to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 10/25] refs: move read_ref, read_ref_full and ref_exists " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 11/25] refs: move resolve_refdup to common Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 12/25] refs: move check_refname_format to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 13/25] refs: move is_branch " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 14/25] refs: move prettify_refname " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 15/25] refs: move ref iterators " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 16/25] refs: move head_ref_namespaced " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 17/25] refs: move transaction functions " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 18/25] refs: move refname_is_safe " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 19/25] refs: move copy_msg " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 20/25] refs: move peel_object " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 21/25] refs: move should_autocreate_reflog to " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 22/25] initdb: make safe_create_dir public Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 23/25] files_log_ref_write: new function Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 24/25] refs: create a shared version of verify_refname_available Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 25/25] refs: break out ref conflict checks Michael Haggerty
2015-11-04 21:01     ` David Turner
2015-11-05  4:00       ` Michael Haggerty
2015-11-05 16:22         ` David Turner
2015-11-06 13:34           ` Michael Haggerty
2015-11-06 17:28             ` Junio C Hamano
2015-11-06 23:24               ` Junio C Hamano [this message]
2015-11-08  5:03                 ` Michael Haggerty
2015-11-08  5:54                   ` Michael Haggerty
2015-11-08 18:23                   ` Junio C Hamano

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=xmqqd1vm3e59.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    /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).