git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Pitfalls in auto-fast-forwarding heads that are not checked out?
@ 2013-05-03 22:46 Martin Langhoff
  2013-05-04  7:34 ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Langhoff @ 2013-05-03 22:46 UTC (permalink / raw)
  To: Git Mailing List

I am building a small git wrapper around puppet, and one of the
actions it performs is auto-fastforwarding of branches without
checking them out.

In simplified code... we ensure that we are on a head called master,
and in some cases "ppg commit", will commit to master and...

  ## early on
  # sanity-check we are on master
  headname=$(git rev-parse --symbolic-full-name --revs-only HEAD)
  if [ "$headname" -ne "refs/heads/headname" ]; then
      echo >&2 "ERROR: can only issue --immediate commit from the
master branch!"
      exit 1
  fi

  ## then
  git commit -bla blarg baz

  ## and then...

  # ensure we can ff
  head_sha1=$(git rev-parse --revs-only master)
  mb=$(git merge-base $production_sha1 refs/heads/master)
  if [[ "$mb" -ne "$production_sha1" ]]; then
      echo >&2 "ERROR: cannot fast-forward master to production"
      exit 1
  fi
  $GIT_EXEC_PATH/git-update-ref -m "ppg immediate commit"
refs/heads/production $head_sha1 $production_sha1 || exit 1

Are there major pitfalls in this approach? I cannot think of any, but
git has stayed away from updating my local tracking branches; so maybe
there's a reason for that...

cheers,


m
--
 martin.langhoff@gmail.com
 -  ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 ~ http://docs.moodle.org/en/User:Martin_Langhoff

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

end of thread, other threads:[~2013-05-07 14:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-03 22:46 Pitfalls in auto-fast-forwarding heads that are not checked out? Martin Langhoff
2013-05-04  7:34 ` Johannes Sixt
2013-05-04 11:35   ` Martin Langhoff
2013-05-04 13:17     ` John Szakmeister
2013-05-04 18:51     ` Jonathan Nieder
2013-05-07 14:27       ` Martin Langhoff

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