git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A git problem with timestamps
@ 2008-09-07 13:54 Rod
  2008-09-07 20:03 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Rod @ 2008-09-07 13:54 UTC (permalink / raw)
  To: git

I have a problem with a git repository that I'm hoping you folks can help me 
with. 

If you folks have the time here's my situation:
============================
2 persons developing together (Fred and Barney if you will). Fred's repository 
is the canonical repository, Barney cloned from Fred, and periodically has 
Fred pull Barney's work, and if it passes muster, merge it into Fred's 
master. Barney is good about pulling Fred's master into his own master 
periodically and basing his work off the master branch.

Fred starts with source code that is not his own (or under version control), 
but that he needs to clean up with help from Barney.

Now Fred is a conscientious Linux user and uses ntp to make sure his system 
date is in sync within a couple of milliseconds of UTC. Barney (that would be 
me) is a slacker too lazy to run ntpclient, or ntpd to make sure he's also 
in sync with UTC. In point of fact, Barney's clock says he's 6 hours earlier 
than Fred (i.e., when Fred's system clock say it's 6 p.m., Barney's clock say 
it's noon.).

Git has no problem keeping track of the order in which commits occurs as gitk 
clearly shows. But git log has a problem since it's ordering by time stamps, 
so it shows Fred's initial commit occurring *After* some commits pulled from 
Barney's repository. 

What's really bugging Fred and Barney is that Fred has received a new updated 
version of the original source code he was tasked to clean up. What Fred and 
Barney would like to do is to make a branch of the repository from the base 
of master, and then apply the history of master onto this branch. For 
personal reasons, they don't want to simply rebase master off this branch.

To be a little more specific, what Fred and  Barney would like to do is to 
branch master's base node (not HEAD), call it "updated_original_source_code", 
unroll the "updated" original source code in this branch, commit the diffs 
from the original source code to "updated" original source code, and then 
apply the history of master by using git-format-patch and git-am to generate 
a sequence of patches to apply onto updated_original_source_code branch. 

The problem is that the patches generated by git-format-patch are generated by 
timestamp, and since slacker Barney's timestamps are off by 6 hours, some of 
the patches would be applied in the wrong order thus borking the operation. 
Have you any suggestions for how to get around this problem? I'm sure I can't 
be the only person to have used the wrong system clock time.

Here are the git commands Fred is attempting to use:
# Branch the *base* of master
git checkout -b updated_original_source_code 345678

cp ../updated_source_code.tar.gz .
tar zxvf updated_source_code.tar.gz

# Commit all changes from original_source_code
# to updated_source_code
git -a -m "Updated original source code"

# Now apply the history of master onto this branch:
# This is where they get hosed because the timestamps
# from Barney's commits are wrong, and hence the 
# generated patches are out of order.
git format-patch 345678..master | git am -k -3

--Rod

P.s. Would a diagram help?

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

* Re: A git problem with timestamps
  2008-09-07 13:54 A git problem with timestamps Rod
@ 2008-09-07 20:03 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2008-09-07 20:03 UTC (permalink / raw)
  To: Rod; +Cc: git

Rod <armyofthepenguin@gmail.com> writes:

> Here are the git commands Fred is attempting to use:
> # Branch the *base* of master
> git checkout -b updated_original_source_code 345678
>
> cp ../updated_source_code.tar.gz .
> tar zxvf updated_source_code.tar.gz
>
> # Commit all changes from original_source_code
> # to updated_source_code
> git -a -m "Updated original source code"
>
> # Now apply the history of master onto this branch:
> # This is where they get hosed because the timestamps
> # from Barney's commits are wrong, and hence the 
> # generated patches are out of order.
> git format-patch 345678..master | git am -k -3

First of all, the branch name "updated_original_source_code" does not make
much sense.  When you get another round of source tarball update, what
would you do?  Create "updated_original_source_code_2"?  The one after
that is "updated_original_source_code_3"?

That misses the whole point of revision control, doesn't it?

You instead keep an "upstream" branch, whose tip might be at 345678 before
accepting the tarball update, and you advance its tip only with the
upstream updates:

      Barney               o---o---o       o---o
                          /         \     /     \
      Fred   o---o---o---o---o---o---o---o---o---o
            /
        ---o---------------------------------------o
           ^                                       ^
           upstream ===== (tarball update) ======> upstream

You can tag its tip after every time you accept the tarball update from
your upstream.

A natural thing to do from there is to _merge_ upstream changes to your
shared development, that results in:


      Barney               o---o---o       o---o
                          /         \     /     \
      Fred   o---o---o---o---o---o---o---o---o---o---*
            /                                       /
        ---o---------------------------------------o
           ^                                       ^
           upstream ===== (tarball update) ======> upstream

Of course you could rebase all history on top of updated upstream (buy why
bother? -- you are not keeping a linear history by cross merging between
two developers already, so there is no point doing a "format-patch | am"
sequence to linearlize your history at this point), and --topo-order given
to format-patch may help with broken timestamps one of you recorded.

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

end of thread, other threads:[~2008-09-07 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-07 13:54 A git problem with timestamps Rod
2008-09-07 20:03 ` Junio C Hamano

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).