From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: Simplify "git reset --hard"
Date: Mon, 15 May 2006 08:09:31 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0605150807030.3866@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0605150752490.3866@g5.osdl.org>
On Mon, 15 May 2006, Linus Torvalds wrote:
>
> Ack. On the other hand, I wonder if it might not make sense to have this
> part potentially depend on the "--reset" flag.
>
> That way you wouldn't even have to apologize for it.
Ie, something like this..
This should allow a two-way or three-way merge to akso ignore any dirty
state when you use "--reset", because they use "verify_uptodate()", which
now would set the CD_UPDATE flag on the ce rather than complain about it
being different (if it survives the merge, of course - often it won't, but
then we won't care).
This is all totally untested, of course.
Linus
----
diff --git a/read-tree.c b/read-tree.c
index 7c83031..f2d674c 100644
--- a/read-tree.c
+++ b/read-tree.c
@@ -13,6 +13,7 @@ #include "cache-tree.h"
#include <sys/time.h>
#include <signal.h>
+static int reset = 0;
static int merge = 0;
static int update = 0;
static int index_only = 0;
@@ -419,6 +420,10 @@ static void verify_uptodate(struct cache
return;
errno = 0;
}
+ if (reset) {
+ ce->ce_flags |= htons(CE_UPDATE);
+ return;
+ }
if (errno == ENOENT)
return;
die("Entry '%s' not uptodate. Cannot merge.", ce->name);
@@ -723,6 +728,11 @@ static int oneway_merge(struct cache_ent
return deleted_entry(old, NULL);
}
if (old && same(old, a)) {
+ if (reset) {
+ struct stat st;
+ if (lstat(old->name, &st) || ce_match_stat(old, &st, 1))
+ old->ce_flags |= htons(CE_UPDATE);
+ }
return keep_entry(old);
}
return merged_entry(a, NULL);
@@ -790,7 +800,7 @@ static struct cache_file cache_file;
int main(int argc, char **argv)
{
- int i, newfd, reset, stage = 0;
+ int i, newfd, stage = 0;
unsigned char sha1[20];
merge_fn_t fn = NULL;
prev parent reply other threads:[~2006-05-15 15:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-14 17:43 Allow one-way tree merge to remove old files Linus Torvalds
2006-05-14 17:51 ` Junio C Hamano
2006-05-14 18:20 ` Simplify "git reset --hard" Linus Torvalds
2006-05-15 6:55 ` Junio C Hamano
2006-05-15 7:08 ` Junio C Hamano
2006-05-15 7:46 ` Junio C Hamano
2006-05-15 14:55 ` Linus Torvalds
2006-05-15 15:09 ` Linus Torvalds [this message]
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=Pine.LNX.4.64.0605150807030.3866@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.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).