From patchwork Thu Feb 1 11:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13540937 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C8F24D9FF for ; Thu, 1 Feb 2024 11:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788709; cv=none; b=jsOnz89Z+tOXUY+7+dHUyjGINiDaP7i9kcvqbDhLzhrafk8mPld770Q/2+7zTbPqKlklKZjSZs6Dr/K/zvv9jifqkCh/bJECRcEG3UkQep+HO6Cr2tBZccpbhFYPvDbeksWt9u3P9PmFItoOT9flb/6SqZgEBmkpFfLfvsfHwGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788709; c=relaxed/simple; bh=c6NuoEPV2b5MqMtHYDF6h4XhoAfGJaCazNzoIZEn5mY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eCNMiCfqH1yymfKx3qhZLprkDxPoe7UyczEYk3LK2sXPqIlZXU3jg2p3YmRMpBRXmxCbnccO1ro5X74abQRP4wynFcmEzFuToPO+OyEj9GkIsa4hMpUqwE/CNhXajn9HQ/IxHkXin6iHrSGKvkF9e5AZS0EZ2Jn9R5jy5T1YCas= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KfX1fDD4; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KfX1fDD4" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5111e5e4e2bso1279210e87.3 for ; Thu, 01 Feb 2024 03:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706788705; x=1707393505; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cUaQ64beMWrLIMpaF6W97IbkMP2Q53oP91SRuxFXnHI=; b=KfX1fDD4aSOBGMi0q/E9Qz/229V6avC2FOY57Gz5O6xNHeaewg35QMQIqEicgbmjCg K/NhxGsVYjYA4ZTWIglq+JO6ReT+twTPXMmRsS81MsR+chph3xeEd2JX/hviPTKChqsp BBzz3Nj2RnjVXghM27wS3KyBcdXTu1JJ4e7zZfEDBBOURMlDX40Wwel8mOGTs1PT+CSA b/Yq3MIVJ2Wav70oFpzWNA5yttA8MwGJjcSrCl4+5CGuhgBbla7gvkyHEH3JD3zBA9fl FCYmgnOdTzMQGeZqQzF+Xl+YzcIe3s/aN7kcYld2llLMxPKFVSNTZ9mCqzl71UMIVyY+ x8eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706788705; x=1707393505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cUaQ64beMWrLIMpaF6W97IbkMP2Q53oP91SRuxFXnHI=; b=qiQTPcbNydavLDUV8QS325whZJeJLIR6hss+1GwR9ECw9u3U3p3z7OV4i9Ygh7pu5x l81/ttfQnWXU1fH90IDBBnJdMVzvaJqudOtnulHMNbLwfEpko7p5+mLJ5/GfUhaYJoag 6RM+zXyInk/P+53cXyhY+uGM5LJYYxdIgc7Oi4X0LRLBq4swY53uqvY9Mx9IhO1hbrhv Ps/RK8IEI7TchGq1fnkgaxAPY201Awg9xhMV9MsYwbokpxfpUnCIJCWMRevWwuMsCkem iTKJnVXaoaAZ2nOvKQJVEhJFFfafIZc6wBxQHdi18ibWaXSlxeRLYncCG8dmbUVqvuGt AdkA== X-Gm-Message-State: AOJu0Ywt/lwjB4Apoo5GGef+Kb7DypRDW1EetQHIM8tAlg1iXvcnr7XG aIFVd53ssWNzedQ8sYqzbP7uyVTSUTvurqzcDz2KdJquaKaKjbbe452FXqek X-Google-Smtp-Source: AGHT+IEI2lHpfstmJvcXIChEhHstl1Cp96EP4zgiZ7fOR+qAOJFQrbH3FkQVlImn/vDy4DVvZQNjNQ== X-Received: by 2002:a05:6512:e86:b0:510:14c5:3360 with SMTP id bi6-20020a0565120e8600b0051014c53360mr1675163lfb.65.1706788704882; Thu, 01 Feb 2024 03:58:24 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV4MKz+uenWKRz6KtnStYqTFjNbLICfmPINhrvi98MN4Bqmb9mQC+OauFMvW3lPHVzYObKHZSxMSTyde24uHGJ0LZlBhHdztuoEtISJREXxr+MV1BdHDIeic2SvjliIoRJ6B9g7kwn32Xjvjn4m0a9ZMkf+8pY2CO5zKuGU4fa72P8wCw== Received: from localhost.localdomain ([2001:861:3f04:7ca0:e1e0:bb55:1733:6146]) by smtp.gmail.com with ESMTPSA id s6-20020a05600c044600b0040faf410320sm4113495wmb.20.2024.02.01.03.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:58:24 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Christian Couder , Christian Couder Subject: [PATCH 1/3] revision: clarify a 'return NULL' in get_reference() Date: Thu, 1 Feb 2024 12:58:07 +0100 Message-ID: <20240201115809.1177064-2-christian.couder@gmail.com> X-Mailer: git-send-email 2.43.0.496.g8be34ce359 In-Reply-To: <20240201115809.1177064-1-christian.couder@gmail.com> References: <20240201115809.1177064-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In general when we know a pointer variable is NULL, it's clearer to explicitely return NULL than to return that variable. In get_reference() when 'object' is NULL, we already return NULL when 'revs->exclude_promisor_objects && is_promisor_object(oid)' is true, but we return 'object' when 'revs->ignore_missing' is true. Let's make the code clearer and more uniform by also explicitely returning NULL when 'revs->ignore_missing' is true. Signed-off-by: Christian Couder --- revision.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revision.c b/revision.c index 2424c9bd67..4c5cd7c3ce 100644 --- a/revision.c +++ b/revision.c @@ -385,7 +385,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name, if (!object) { if (revs->ignore_missing) - return object; + return NULL; if (revs->exclude_promisor_objects && is_promisor_object(oid)) return NULL; die("bad object %s", name); From patchwork Thu Feb 1 11:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13540938 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C239715D5C5 for ; Thu, 1 Feb 2024 11:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788711; cv=none; b=c7h63G1LzPXdfj5cT+Cdzg3t3T1Bkn0Fu6Ea7Xdf+XYEg+3Cj2PFP/A2vCuPB06GUtJqJqXEoS6b+r1QdB+S3EQmM4q6Epq0oMAl9STTtpG/IZ+czFqQlOgQQgIY2gDoNCgpDhOb43/nCp9wyr521KrQSmhIsb6AdNC05+J//SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788711; c=relaxed/simple; bh=aeQ3Erh/fbZ/PZ300U8hAloeC9Tfa3iEu8AJceU6/1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KKMsvrqKZ7ScMhDMt88xjIPn3z1VAfIaSTxjT1x+uhl1Cx5LPwnaz8zx7Y7k1W4udG0eo2T598hSyj3uUZfprdGgy1YeiTAbOee6Hlh4Db4Aao4d+xXudlMZJIuLLmHnFcF7qGSaZ9T2NWKHqN8Akxi2Sd6X/GH1H6uOeG6O6TQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VMen5QQx; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VMen5QQx" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51121637524so1112726e87.1 for ; Thu, 01 Feb 2024 03:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706788707; x=1707393507; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kv+cJ7ob1td5pzKZwFqj5zOW6fAB39eybS77es30yB0=; b=VMen5QQxi+XKAptwFJVA2WifNN5cixnKzSNpmrOfPk7UbwMHOR2g9CJIeHY28JrWs8 igzhAofJlYJXMoqvYPIXqJG1Dmhf1w0HwGiAPmHj58xAEE/Pe56NmZf20cMGMmqvky/P kG9fJTOh9bDSchI94xXKsbLJpa9tskrnMka7zqQ45q6gkudbdKgo0s4UlGiPD3Lr1vt0 YdZE1NiWadCS9lsSt9+XxXO9EWTQSrLMxQVpO+SR85XrwGs5wVehr1svSPZhost6cfxI u+2iyLbs5DGeUwGt98AXxFurKZoehaT4z0XM2VDSfCN5pOWHSbEj5mhtp+gUb1g/dDOu //PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706788707; x=1707393507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kv+cJ7ob1td5pzKZwFqj5zOW6fAB39eybS77es30yB0=; b=rse4LAb5Ts56Keetstvba9Hbl1p0TJtPuYqrgYyUMX8yonE/KzOMlaP6qNrPJjh16y PoyB+WjtpaNO05s0QYs5t66GAmOf/RXw4R7d76cm4oBxks5p4cAiIXxeVOkKNQVjtrjG REZDA3pMiWXcJESFyJScNGipQQy8bnkghnUT2mIwU+/obAxqA/2x7q2ZbV02B0yoId53 q5fy0h5VDCMfiW53/F4rPAb7t+n1SnufGSyzQWqrOjmc+kZ57mJ8yVtuTizSgMV0VcRK IJw2f98pKQtJbURRntwvOtEbth/r8fRi6/jaWwSI4qOz9C9QAEdXyRoUqL1AEP4whYG6 fl+w== X-Gm-Message-State: AOJu0YwtQgDG7WZuIWjEjBfVu+/AQ+QrbJV8sNYTGi8IwuHJ2zbV70aH 9xhI3OZf7BL3NBHFHKf+ghOmG10LCKOms1p3Q3p7Gm4YgcbwPFbt4j04s9Zf X-Google-Smtp-Source: AGHT+IHT7F/09Sth6L3oP0fqCQJHMZvllEke3miIDA8P59bf3ds6r7l6+aTeF4K0bozX5yMUTqlHqA== X-Received: by 2002:ac2:558a:0:b0:511:22ba:c0a7 with SMTP id v10-20020ac2558a000000b0051122bac0a7mr1592830lfg.17.1706788706957; Thu, 01 Feb 2024 03:58:26 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV5aDy38cdfJ+UWW6PLClDxdENpPOhvrpOLD+BxdkfWleFRCsQnHM59utOkch9eQ7Qt9qVFIV5kUR4pS2rRY1TX2TRjFIGmA5DWfYscpru4LOFxRJjrA5DQMN06S+hJ2gmYa6yBLqn3QIdTfrKSpoGURGHmDVLV4bYs6n9QvCpgnL02cQ== Received: from localhost.localdomain ([2001:861:3f04:7ca0:e1e0:bb55:1733:6146]) by smtp.gmail.com with ESMTPSA id s6-20020a05600c044600b0040faf410320sm4113495wmb.20.2024.02.01.03.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:58:25 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Christian Couder , Christian Couder Subject: [PATCH 2/3] t6022: fix 'even though' typo in comment Date: Thu, 1 Feb 2024 12:58:08 +0100 Message-ID: <20240201115809.1177064-3-christian.couder@gmail.com> X-Mailer: git-send-email 2.43.0.496.g8be34ce359 In-Reply-To: <20240201115809.1177064-1-christian.couder@gmail.com> References: <20240201115809.1177064-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Christian Couder --- t/t6022-rev-list-missing.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 211672759a..527aa94f07 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -46,7 +46,7 @@ do git rev-list --objects --no-object-names \ HEAD ^$obj >expect.raw && - # Blobs are shared by all commits, so evethough a commit/tree + # Blobs are shared by all commits, so even though a commit/tree # might be skipped, its blob must be accounted for. if [ $obj != "HEAD:1.t" ]; then echo $(git rev-parse HEAD:1.t) >>expect.raw && From patchwork Thu Feb 1 11:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 13540939 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F15EA15D5CD for ; Thu, 1 Feb 2024 11:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788711; cv=none; b=gBLACtOoNxqLZPDD6SBTI/xE1NBSij5mo3/5scME/E1BeyMNk5c8f6qm4Yc3+pG9+8kztKUgOicMmOCTxTXQ7+lHIct/4iOuP3hO0YblZhXip29Uts+dVoEv642+ReJkPqAdvwdEkgcV7qFmouqjo1H13YItn9XIupjVNhxpBF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706788711; c=relaxed/simple; bh=XbSHRVumd1AvdUhxJ9qt2B3cOH/Vtfuigu3+PHXbnrc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L+T8O9WTsx5Nv7SzX+7wRnJZp7G0mOiIg8gD3KoR8YYvga0YZgkX0QifvTZzC1n+P50ENrmE3D2pnGs0P6kVOOF1LCTPo/Cu/1ckHCPTZpRqF/UPZV7Q4xXxVVy1OdZ0F5kqd6TKrmjvgUWxOcifWD4SiqU+YlyYU3MQtZOed78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iocIu9Av; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iocIu9Av" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40fc22f372cso1873025e9.1 for ; Thu, 01 Feb 2024 03:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706788708; x=1707393508; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LcKsU9JqpXSJelpyzTEGSLw5a1rboJTYABh7FieK0jA=; b=iocIu9AvgTvh5Wa0X8/Hd0Y7/cXOg1l73yrOtueXIDX5gp9CB/xUxXL6z5lR27FaBw XRypXfMD0j5KiJFzfj9OhCGTcTMBPoqksGDnQSfozuJ11MgVKuIgw/+OqNlVn7iudCbO k8rZj+86qoGCbm/qJ0OL+FX67GgN6mZViFHbVkHWTzfD8Ej3LvSZY3I6hh+JJEG5fl/u gw4W/A9mNFPmp+dT01Mcgahwy08ldFCpktrqOBSsA5Vs8R0VuGzr63dIsiYqdxKatHvN q4l75/tkh7MyTEiOaMdlbOKyYnqZA0S4sycfoQ8AJddjL6SrWOi6+YOgVGoMLr7nLr/B VIFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706788708; x=1707393508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LcKsU9JqpXSJelpyzTEGSLw5a1rboJTYABh7FieK0jA=; b=p/iXpoxJ+hW4DFTyBezVlxOjGMs34u8weTZJgqsTrel9gQF2tl9ru8nLFN4BQJCx3D sMfKExwUJEazcpp5daEQORGSWPD76PfQ+JL4h94urKdWrECdY2A/vGkrj3JJ/Y1DaRIg G6sOLStdmXQlk/rSTI1XDFZHMwNn5VjExCTmRUaDFGY3hlXADYRpXnnFXFcfK9LMB7D0 EU4m/zP0R5+hoYtJn9yRVg4zXzARIh1yCNJy3qEqQ3CC6V982AHPnZtHQn5OQWyIRcK5 gLl27edEWM85gLlxG25Gul8oUDMRJPvW2mISR7EZ1sfIVB6wL1mnyDv1o51eWaRC3pgP iN+g== X-Gm-Message-State: AOJu0YwndZF1u7f1VqMg5acEHB8Iep28OYSZVVJEmDZoN2E2rWWSQOQM kFRRS38EnAa+wCSz7WI0P4tfCXLUUR3ItBH1shCAjAqT27vuw8MM6NgHQ8DY X-Google-Smtp-Source: AGHT+IFH6YzcJVuozzjOx40AGklJfKBzEeRfkKeTV3M3dW3d1RZoH9qdd+sDqnDKm8t8YQPuMhbMWw== X-Received: by 2002:a05:600c:1907:b0:40e:fc39:716c with SMTP id j7-20020a05600c190700b0040efc39716cmr3600724wmq.4.1706788707712; Thu, 01 Feb 2024 03:58:27 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVJ0yS0IPaCah4S1ZCkj7FMIhR4uD6F+E9pTvEUC4zyqp3HbThnUwtrHzKREoUiT1o/E9blyopU0pFIZN8iZOB60OIP64bnfFNlP/4fY/FnQWhGjtAN7TtYhPb9cr5pwBJA1qJwWN3d9gDFD4PcdjQJ8LnlaWwDCckbVZyeiUU0MSsVWw== Received: from localhost.localdomain ([2001:861:3f04:7ca0:e1e0:bb55:1733:6146]) by smtp.gmail.com with ESMTPSA id s6-20020a05600c044600b0040faf410320sm4113495wmb.20.2024.02.01.03.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:58:27 -0800 (PST) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , John Cai , Christian Couder , Christian Couder Subject: [PATCH 3/3] rev-list: add --allow-missing-tips to be used with --missing=... Date: Thu, 1 Feb 2024 12:58:09 +0100 Message-ID: <20240201115809.1177064-4-christian.couder@gmail.com> X-Mailer: git-send-email 2.43.0.496.g8be34ce359 In-Reply-To: <20240201115809.1177064-1-christian.couder@gmail.com> References: <20240201115809.1177064-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In 9830926c7d (rev-list: add commit object support in `--missing` option, 2023-10-27) we fixed the `--missing` option in `git rev-list` so that it now works with commits too. Unfortunately, such a command would still fail with a "fatal: bad object " if it is passed a missing commit, blob or tree as an argument. When such a command is used to find the dependencies of some objects, for example the dependencies of quarantined objects, it would be better if the command would instead consider such missing objects, especially commits, in the same way as other missing objects. If, for example `--missing=print` is used, it would be nice for some use cases if the missing tips passed as arguments were reported in the same way as other missing objects instead of the command just failing. Let's introduce a new `--allow-missing-tips` option to make it work like this. Signed-off-by: Christian Couder --- builtin/rev-list.c | 24 ++++++++++++++++- revision.c | 9 ++++--- revision.h | 8 ++++++ t/t6022-rev-list-missing.sh | 51 +++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index b3f4783858..ae7bb15478 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -562,6 +562,16 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) break; } } + for (i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (!strcmp(arg, "--allow-missing-tips")) { + if (arg_missing_action == MA_ERROR) + die(_("option '%s' only makes sense with '%s' set to '%s' or '%s'"), + "--allow-missing-tips", "--missing=", "allow-*", "print"); + revs.do_not_die_on_missing_tips = 1; + break; + } + } if (arg_missing_action) revs.do_not_die_on_missing_objects = 1; @@ -627,6 +637,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) continue; /* already handled above */ if (skip_prefix(arg, "--missing=", &arg)) continue; /* already handled above */ + if (!strcmp(arg, "--allow-missing-tips")) + continue; /* already handled above */ if (!strcmp(arg, ("--no-object-names"))) { arg_show_object_names = 0; @@ -753,9 +765,19 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (arg_print_omitted) oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE); - if (arg_missing_action == MA_PRINT) + if (arg_missing_action == MA_PRINT) { + struct oidset_iter iter; + struct object_id *oid; + oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE); + /* Already add missing commits */ + oidset_iter_init(&revs.missing_commits, &iter); + while ((oid = oidset_iter_next(&iter))) + oidset_insert(&missing_objects, oid); + oidset_clear(&revs.missing_commits); + } + traverse_commit_list_filtered( &revs, show_commit, show_object, &info, (arg_print_omitted ? &omitted_objects : NULL)); diff --git a/revision.c b/revision.c index 4c5cd7c3ce..9f25faa249 100644 --- a/revision.c +++ b/revision.c @@ -388,6 +388,10 @@ static struct object *get_reference(struct rev_info *revs, const char *name, return NULL; if (revs->exclude_promisor_objects && is_promisor_object(oid)) return NULL; + if (revs->do_not_die_on_missing_tips) { + oidset_insert(&revs->missing_commits, oid); + return NULL; + } die("bad object %s", name); } object->flags |= flags; @@ -1947,6 +1951,7 @@ void repo_init_revisions(struct repository *r, init_display_notes(&revs->notes_opt); list_objects_filter_init(&revs->filter); init_ref_exclusions(&revs->ref_excludes); + oidset_init(&revs->missing_commits, 0); } static void add_pending_commit_list(struct rev_info *revs, @@ -2184,7 +2189,7 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl verify_non_filename(revs->prefix, arg); object = get_reference(revs, arg, &oid, flags ^ local_flags); if (!object) - return revs->ignore_missing ? 0 : -1; + return (revs->ignore_missing || revs->do_not_die_on_missing_tips) ? 0 : -1; add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags); add_pending_object_with_path(revs, object, arg, oc.mode, oc.path); free(oc.path); @@ -3830,8 +3835,6 @@ int prepare_revision_walk(struct rev_info *revs) FOR_EACH_OBJECT_PROMISOR_ONLY); } - oidset_init(&revs->missing_commits, 0); - if (!revs->reflog_info) prepare_to_use_bloom_filter(revs); if (!revs->unsorted_input) diff --git a/revision.h b/revision.h index 94c43138bc..67435a5d8a 100644 --- a/revision.h +++ b/revision.h @@ -227,6 +227,14 @@ struct rev_info { */ do_not_die_on_missing_objects:1, + /* + * When the do_not_die_on_missing_objects flag above is set, + * a rev walk could still die with "fatal: bad object " + * if one of the tips it is passed is missing. With this flag + * such a tip will be reported as missing too. + */ + do_not_die_on_missing_tips:1, + /* for internal use only */ exclude_promisor_objects:1; diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh index 527aa94f07..283e8fc2c2 100755 --- a/t/t6022-rev-list-missing.sh +++ b/t/t6022-rev-list-missing.sh @@ -77,4 +77,55 @@ do done done +for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t" +do + for tip in "" "HEAD" + do + for action in "allow-any" "print" + do + test_expect_success "--missing=$action --allow-missing-tips with tip '$obj' missing and tip '$tip'" ' + oid="$(git rev-parse $obj)" && + path=".git/objects/$(test_oid_to_path $oid)" && + + # Before the object is made missing, we use rev-list to + # get the expected oids. + if [ "$tip" = "HEAD" ]; then + git rev-list --objects --no-object-names \ + HEAD ^$obj >expect.raw + else + >expect.raw + fi && + + # Blobs are shared by all commits, so even though a commit/tree + # might be skipped, its blob must be accounted for. + if [ "$tip" = "HEAD" ] && [ $obj != "HEAD:1.t" ]; then + echo $(git rev-parse HEAD:1.t) >>expect.raw && + echo $(git rev-parse HEAD:2.t) >>expect.raw + fi && + + mv "$path" "$path.hidden" && + test_when_finished "mv $path.hidden $path" && + + git rev-list --missing=$action --allow-missing-tips \ + --objects --no-object-names $oid $tip >actual.raw && + + # When the action is to print, we should also add the missing + # oid to the expect list. + case $action in + allow-any) + ;; + print) + grep ?$oid actual.raw && + echo ?$oid >>expect.raw + ;; + esac && + + sort actual.raw >actual && + sort expect.raw >expect && + test_cmp expect actual + ' + done + done +done + test_done