From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-6.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id E920C20179 for ; Sun, 3 Jul 2016 08:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbcGCIAg (ORCPT ); Sun, 3 Jul 2016 04:00:36 -0400 Received: from sub3.mail.dreamhost.com ([69.163.253.7]:55589 "EHLO homiemail-a21.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752206AbcGCIAL (ORCPT ); Sun, 3 Jul 2016 04:00:11 -0400 Received: from homiemail-a21.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a21.g.dreamhost.com (Postfix) with ESMTP id 299EF300097; Sun, 3 Jul 2016 00:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=novalis.org; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=novalis.org; bh=yjZCAT6eLKEARFBozw/DwXYcAwQ=; b=szsevwpfz50cmAFdQ5CpFc6Gr5p+ jezpESV5f0HR/5Dc6CqJ6eNdEzYPay/vm22w0Y6k6ZyPaXIBqoYhwpKIHntkZaiH U56ezbn49j2DgjE/3WPrRBoE6H5O3rSpXl0Mom+A0pkQ4QWABIRDCjZRMbmfMZ/2 NoVawiwh6RW+G5c= Received: from frank.cable.rcn.com (207-38-164-98.c3-0.43d-ubr2.qens-43d.ny.cable.rcn.com [207.38.164.98]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: novalis@novalis.org) by homiemail-a21.g.dreamhost.com (Postfix) with ESMTPSA id 75BB230007B; Sun, 3 Jul 2016 00:58:38 -0700 (PDT) From: David Turner To: git@vger.kernel.org, pclouds@gmail.com, kmaggg@gmail.com Cc: David Turner , Junio C Hamano Subject: [PATCH v14 13/21] unpack-trees: preserve index extensions Date: Sun, 3 Jul 2016 03:58:05 -0400 Message-Id: <1467532693-20017-14-git-send-email-novalis@novalis.org> X-Mailer: git-send-email 2.8.0.rc4.11.g9232872.dirty In-Reply-To: <1467532693-20017-1-git-send-email-novalis@novalis.org> References: <1467532693-20017-1-git-send-email-novalis@novalis.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: David Turner Make git checkout (and other unpack_tree operations) preserve the untracked cache and watchman status. This is valuable for two reasons: 1. Often, an unpack_tree operation will not touch large parts of the working tree, and thus most of the untracked cache will continue to be valid. 2. Even if the untracked cache were entirely invalidated by such an operation, the user has signaled their intention to have such a cache, and we don't want to throw it away. The same logic applies to the watchman state. Signed-off-by: David Turner Signed-off-by: Junio C Hamano --- cache.h | 1 + read-cache.c | 8 ++++++++ t/t7063-status-untracked-cache.sh | 22 ++++++++++++++++++++++ t/test-lib-functions.sh | 4 ++++ unpack-trees.c | 1 + 5 files changed, 36 insertions(+) diff --git a/cache.h b/cache.h index 633e1dd..1b372ed 100644 --- a/cache.h +++ b/cache.h @@ -580,6 +580,7 @@ extern void write_watchman_ext(struct strbuf *sb, struct index_state *istate); #define CLOSE_LOCK (1 << 1) extern int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags); extern int discard_index(struct index_state *); +extern void move_index_extensions(struct index_state *dst, struct index_state *src); extern int unmerged_index(const struct index_state *); extern int verify_path(const char *path); extern int index_dir_exists(struct index_state *istate, const char *name, int namelen); diff --git a/read-cache.c b/read-cache.c index 8521e85..bc3c989 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2777,3 +2777,11 @@ void stat_validity_update(struct stat_validity *sv, int fd) fill_stat_data(sv->sd, &st); } } + +void move_index_extensions(struct index_state *dst, struct index_state *src) +{ + dst->untracked = src->untracked; + src->untracked = NULL; + dst->last_update = src->last_update; + src->last_update = NULL; +} diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index a971884..083516d 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -646,4 +646,26 @@ test_expect_success 'test ident field is working' ' test_cmp ../expect ../err ' +test_expect_success 'untracked cache survives a checkout' ' + git commit --allow-empty -m empty && + test-dump-untracked-cache >../before && + test_when_finished "git checkout master" && + git checkout -b other_branch && + test-dump-untracked-cache >../after && + test_cmp ../before ../after && + test_commit test && + test-dump-untracked-cache >../before && + git checkout master && + test-dump-untracked-cache >../after && + test_cmp ../before ../after +' + +test_expect_success 'untracked cache survives a commit' ' + test-dump-untracked-cache >../before && + git add done/two && + git commit -m commit && + test-dump-untracked-cache >../after && + test_cmp ../before ../after +' + test_done diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 8d99eb3..e974b5b 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -186,6 +186,10 @@ test_commit () { test_tick fi && git commit $signoff -m "$1" && + if [ "$(git config core.bare)" = false ] + then + git update-index --force-untracked-cache + fi git tag "${4:-$1}" } diff --git a/unpack-trees.c b/unpack-trees.c index 9f55cc2..fc90eb3 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1215,6 +1215,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options WRITE_TREE_SILENT | WRITE_TREE_REPAIR); } + move_index_extensions(&o->result, o->dst_index); discard_index(o->dst_index); *o->dst_index = o->result; } else { -- 1.9.1