git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: "Ed S. Peschko" <esp5@pge.com>
Cc: Jakub Narebski <jnareb@gmail.com>, git@vger.kernel.org
Subject: Re: simple cvs-like git wrapper
Date: Wed, 30 Jan 2008 23:08:39 -0500	[thread overview]
Message-ID: <20080131040839.GW24004@spearce.org> (raw)
In-Reply-To: <20080130225254.GC9612@venus>

"Ed S. Peschko" <esp5@pge.com> wrote:
> On Tue, Jan 29, 2008 at 11:00:02PM -0500, Shawn O. Pearce wrote:
> 
> well, no, but I'd say 80-90% of the changes we have are ones that we
> want to instantly share with everybody. I was thinking that ones that
> we didn't would be prefixed, as in:
> 
> 	git-branch exp-<change_name>
> 
> and those would need to be renamed explicitly to become 'mainline'
> branches before they were merged..

OK, that's sensible.
 
> You've got some good points, and my original intent was to
> answer them point-by-point, but suffice to say:
> 
> 	1. I was hoping to make each branch correspond to a work request,
> 	   that would be tracked for SOX. We also need to track the changes
> 	   in mercury interactive, not git, so I've got some challenges
> 	   there in making a wrapper to handle this.

Yea, that's not a bad idea, because then if a dev wants to make
multiple small changes before saying they are finished with a
particular request they can.

I've got a script I use at final "intergration" point between
developers and the testing team that scans through all of the commit
messages for all changes since the last integration and updates
our issue database automatically to mark those items in some way.
Rather short Perl script, except for the 1300 lines of hideous C
code to speak to the vendor's tracking software.  We find it works
well to hold off on updating external non-git records until near
the very end.

You do realize that in Git once a branch has been merged you can
delete that branch, and the history of all of those changes remains?
Git itself has probably been built from thousands of individual
branches over the years, yet I'm positive Junio only has a small
handful (25-30) in his working repository that he uses to maintain
Git.  This branches are only the "live" ones that are still being
actively worked on and aren't ready for release.

Yup, there were 1,756 branches that lead up to v1.5.4-rc5:

	$ git rev-list --parents v1.5.4-rc5 \
	  | perl -ne 'print if /.* .* .*/' \
	  | wc -l
    1756

that of course was since the beginning of time.  Since v1.5.3 we
have had about 240:

	$ git rev-list --parents v1.5.3..v1.5.4-rc5 \
	  | perl -ne 'print if /.* .* .*/' \
	  | wc -l
    1756

> 	2. A single, linear history on the remote end wouldn't be easy for
> 	   reporting purposes.
>   3. A single linear history on the remote end wouldn't support 
> 	   the rare cases where I *do* want a single change.

So by this it sounds like you don't want to ever use rebase?
And instead encourage your team to always use git-merge or
git-pull (without its rebase flag).

> I guess my scheme's workability depends on how effective git is at 
> doing merges from branch to branch, and how good it is at fixing
> conflicts in a way that is simple for the user. In CVS, I get: 
> 
>     >>>>>
>     ...
>     =====
>     ...
>     <<<<<
> 
> when a conflict occurs, and you need to resolve that conflict before
> re-committing again. Does git do a similar thing?

Yes.  Git also tries harder to keep you from committing a file that
has an unresolved conflict in it.  Git's merging is a lot smarter
than CVS's ever was, as Git does automatic merge base detection
during each merge, so you don't have to keep track of this yourself.

> Also, with git-ls-remote - is there a way to see more information 
> about the remote branch rather than just its name, ie: can you say:
> 
>     git-ls-remote -l --heads origin
> 
> to get a list of changes in the order they were made? And is there a 
> command that does what I want, ie:

Nope.  To really see anything further you need access to the objects.
That means either executing a tool like git-log directly on the
server, using gitweb through your webbrowser, or fetching the
objects down to your local repository with git-fetch, where you
can then browse them with any git log viewing tool (git-log, gitk,
rev-list, etc.).

> 	git pull origin --all 
> 
> Which pulls all branches from origin and merges them into the current
> branch in an intelligent way, ie: by order in which the branches were 
> committed, or even:

Merging all branches on the remote named "origin" is simply not an
intelligent thing to do.  Nobody blindly merges everything available
from a remote, and nobody has ever asked for such a function before
in Git.  I still think its nuts, but I don't know all details of
your situation so I'll just shut up now and hope you know what you
are really asking for.
 
> 	git pull origin --re: '^(?!exp)'
> 
> which pulls in all branches matching a given regular expression (in this
> case, not matching 'exp' at the beginning..

You can do something like this, but I *really* think this is a
horribly bad idea:

	#!/bin/sh

	# Download all new branches, remove any now deleted branches.
	#
	git fetch || exit
	git remote prune origin || exit

	# Loop through all non-exp branches and merge them
	#
	for b in $(git for-each-ref --format=%(refname) refs/remotes/origin)
	do
		case $b in
		refs/remotes/origin/exp-*)
			: do not merge
			;;
		*)
			echo "==> Merging ${b##refs/remotes/origin/} ..."
			if git merge $b
			then
				: good merge
			else
				echo >&2
				echo >&2 error: Fix conflicts, commit, rerun $0
				exit 1
			fi
		esac
	done

This is going to be slow as you are running git-merge for each
and every branch available to you.  You can do a lot better by
loading the branch DAG into memory in Perl/C/Python and doing a
graph coloring algorithm to see if a merge is necessary or not,
as if you are merging everything all of the time almost everything
is going to be always merged to everything else.  Which as I said
earlier is nuts.

-- 
Shawn.

  reply	other threads:[~2008-01-31  4:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 20:40 simple cvs-like git wrapper Ed S. Peschko
2008-01-29 22:28 ` Jakub Narebski
2008-01-30  2:10   ` Ed S. Peschko
2008-01-30  4:00     ` Shawn O. Pearce
2008-01-30 22:52       ` Ed S. Peschko
2008-01-31  4:08         ` Shawn O. Pearce [this message]
2008-01-31  5:41           ` Ed S. Peschko
2008-01-31  6:01             ` Shawn O. Pearce
2008-01-31  6:17           ` Junio C Hamano
2008-01-30 19:49     ` Daniel Barkalow
2008-02-01 13:05     ` Kate Rhodes
2008-02-01 13:25       ` Johannes Schindelin
2008-02-01 15:35     ` Jakub Narebski
2008-02-01  7:29   ` Uwe Kleine-König
2008-02-01  9:58     ` Jakub Narebski

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

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

  git send-email \
    --in-reply-to=20080131040839.GW24004@spearce.org \
    --to=spearce@spearce.org \
    --cc=esp5@pge.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    /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.
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 NNTP newsgroup(s).