Git合并期间考虑空间

kwvwclae  于 2022-11-20  发布在  Git
关注(0)|答案(2)|浏览(102)

我刚刚意识到Git在默认情况下会忽略合并时的空格。但是,我希望Git在合并时会考虑空格。有人知道我该如何配置它吗?
我试着安装旧版本,但是我找不到。在Ubuntu上安装旧版本的步骤会很好。

fbcarpbf

fbcarpbf1#

Git在合并时不应该忽略空格,除非:

  • 添加-Xignore-all-space(手册页)
  • 或者这些更改已在以前的合并提交中合并
  • 或者您定义了一个忽略空白的合并驱动程序(而普通的本地git merge不会)

OP GLEIPH GHIOTTO LIMA DE MENEZES在注解中确认这是因为合并驱动程序与新的merge default strategy ORT不兼容,导致diff的上下文不同。
现在使用merge -s recursive就足以恢复到遗留行为。

2w2cym1i

2w2cym1i2#

我刚刚意识到Git使用了一个新的策略,叫做ort,这会产生一个不同的结果,允许冲突块的上下文在合并过程中也会改变(在文档https://git-scm.com/docs/git-merge中有描述)。然而,我在我的算法中使用了这个事实(上下文行不会改变)。因此,我把策略改为递归(-s recursive),这就解决了我的问题。
我重放了SAIM(https://github.com/dice-group/SAIM)的合并044 a3 c,我得到了两个不同的答案。不幸的是,没有空间显示这个答案中的结果,我将显示每个策略报告的第一个冲突块。
Ort策略

selfconfig.setEnabled(true);
    }

<<<<<<< HEAD
        private void performPropertyMapping() {
            Configuration config = Configuration.getInstance();
            config.getSource().properties.clear();
            config.getTarget().properties.clear();
            PropertyMapper propMapper = new PropertyMapper();
            String classSource = config.getSource().getClassOfendpoint();
            String classTarget = config.getTarget().getClassOfendpoint();
            if(classSource != null && classTarget != null) {
                showErrorMessage("Getting property mapping...");
                propMapping = propMapper.getPropertyMapping(config.getSource().endpoint,
                        config.getTarget().endpoint, classSource, classTarget);
                for(String s : propMapping.map.keySet())
                    for(Entry<String, Double> e : propMapping.map.get(s).entrySet()) {
                        System.out.println(s + " - " + e.getKey());
                        String s_abr=PrefixHelper.abbreviate(s);
                        sourceProps.add(s_abr);
                        config.getSource().properties.add(s_abr);
                        config.getSource().prefixes.put(PrefixHelper.getPrefixFromURI(s_abr), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s_abr)));
                        System.out.println("Adding source property: "+s_abr+"::::"+PrefixHelper.getPrefixFromURI(s_abr)+" -- "+PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s_abr)));
                        targetProps.add(PrefixHelper.abbreviate(e.getKey()));
                        String t_abr=PrefixHelper.abbreviate(e.getKey());
                        config.getTarget().properties.add(t_abr);
                        config.getTarget().prefixes.put(PrefixHelper.getPrefixFromURI(t_abr), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(t_abr)));
                        System.out.println("Adding target property: "+t_abr+"::::"+PrefixHelper.getPrefixFromURI(t_abr)+" -- "+PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(t_abr)));
=======

    /**
     * Little helper function to retrieve classes out of restrictions of the LIMES SPEC. Whereas, a
     * class is in a restriction of the format "?var rdf:type <class>".
     * @param ep
     * @return
     */
    private String getClassOfEndpoint(KBInfo ep) {
        for(String rest : ep.restrictions) {
            if(rest.matches(".* rdf:type .*"))
                return rest.substring(rest.indexOf("rdf:type")+8).replaceAll("<", "").replaceAll(">", "").trim();
        }
        return null;
    }

    private void showErrorMessage(String message) {
        layout.setComponentError(new UserError(message));
    }

    public boolean isValid() {
        manualMetricForm.validate();
        if(manualMetricForm.isValid()) {
            Configuration.getInstance().setMetricExpression(manualMetricForm.metricTextField.getValue().toString());
            Configuration.getInstance().setAcceptanceThreshold(Double.parseDouble(manualMetricForm.thresholdTextField.getValue().toString()));
            return true;
        } else {
            manualMetricForm.setComponentError(new UserError("Please insert something..."));
        }
        return false;
    }

    public class SelfConfigClickListener implements Button.ClickListener {
        Layout l;
        public SelfConfigClickListener(Layout l) {
            this.l=l;
        }
        @Override
        public void buttonClick(ClickEvent event) {
            // add all properties
            for(String s : sourceProps) {
                Configuration.getInstance().getSource().properties.add(s);
                Configuration.getInstance().getSource().prefixes.put(PrefixHelper.getPrefixFromURI(s), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s)));
                Configuration.getInstance().getSource().functions.put(s, "");
            }
            for(String s : targetProps) {
                Configuration.getInstance().getTarget().properties.add(s);
                Configuration.getInstance().getTarget().prefixes.put(PrefixHelper.getPrefixFromURI(s), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s)));
                Configuration.getInstance().getTarget().functions.put(s, "");
            }
            // run selfconfig
            l.removeAllComponents();
            Refresher refresher = new Refresher();
            SelfConfigRefreshListener listener = new SelfConfigRefreshListener();
            refresher.addListener(listener);
            addComponent(refresher);

            final ProgressIndicator indicator = new ProgressIndicator();
            indicator.setCaption("Progress");
            l.addComponent(indicator);
            indicator.setImmediate(true);

            final Panel stepPanel = new Panel("Starting self configuration");
            l.addComponent(stepPanel);

            new Thread() {
                public void run() {

                    float steps = 5f;
                    indicator.setValue(new Float(1f/steps));
                    indicator.requestRepaint();
                    stepPanel.setCaption("Getting source cache...");
                    HybridCache sourceCache = HybridCache.getData(Configuration.getInstance().getSource());
                    indicator.setValue(new Float(2f/steps));
                    indicator.requestRepaint();
                    stepPanel.setCaption("Getting target cache...");
                    HybridCache targetCache = HybridCache.getData(Configuration.getInstance().getTarget());
                    indicator.setValue(new Float(3f/steps));
                    stepPanel.setCaption("Performing self configuration...");
                    MeshBasedSelfConfigurator bsc = new MeshBasedSelfConfigurator(sourceCache, targetCache, 0.6, 0.5);
                    List<SimpleClassifier> cp = bsc.getBestInitialClassifiers();                        
                    indicator.setValue(new Float(4f/steps));
                    stepPanel.setCaption("Performed self configuration:");
                    for(SimpleClassifier cl : cp) {
                        System.out.println(cl);
>>>>>>> bbb3f6b
                    }

                }

递归策略

final int WIDTH = 800;
        final int NODESIZE = 100;

<<<<<<< HEAD
        private void performPropertyMapping() {
            Configuration config = Configuration.getInstance();
            config.getSource().properties.clear();
            config.getTarget().properties.clear();
            PropertyMapper propMapper = new PropertyMapper();
            String classSource = config.getSource().getClassOfendpoint();
            String classTarget = config.getTarget().getClassOfendpoint();
            if(classSource != null && classTarget != null) {
                showErrorMessage("Getting property mapping...");
                propMapping = propMapper.getPropertyMapping(config.getSource().endpoint,
                        config.getTarget().endpoint, classSource, classTarget);
                for(String s : propMapping.map.keySet())
                    for(Entry<String, Double> e : propMapping.map.get(s).entrySet()) {
                        System.out.println(s + " - " + e.getKey());
                        String s_abr=PrefixHelper.abbreviate(s);
                        sourceProps.add(s_abr);
                        config.getSource().properties.add(s_abr);
                        config.getSource().prefixes.put(PrefixHelper.getPrefixFromURI(s_abr), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s_abr)));
                        System.out.println("Adding source property: "+s_abr+"::::"+PrefixHelper.getPrefixFromURI(s_abr)+" -- "+PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(s_abr)));
                        targetProps.add(PrefixHelper.abbreviate(e.getKey()));
                        String t_abr=PrefixHelper.abbreviate(e.getKey());
                        config.getTarget().properties.add(t_abr);
                        config.getTarget().prefixes.put(PrefixHelper.getPrefixFromURI(t_abr), PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(t_abr)));
                        System.out.println("Adding target property: "+t_abr+"::::"+PrefixHelper.getPrefixFromURI(t_abr)+" -- "+PrefixHelper.getURI(PrefixHelper.getPrefixFromURI(t_abr)));
                    }
            } else {
                showErrorMessage("Cannot perform automatic property mapping due to missing class specifications.");
            }       
        }
=======
        Cytoscape.createNewSession();   
        String name = "MyName";
        CyNetwork cyNetwork = Cytoscape.createNetwork(name, false);     
        cyNetworkView = Cytoscape.createNetworkView(cyNetwork);

        cytographer = new Cytographer(cyNetwork, cyNetworkView, name, WIDTH, HEIGHT);
        cytographer.setImmediate(true);
        cytographer.setWidth(WIDTH + "px");
        cytographer.setHeight(HEIGHT + "px");
        cytographer.setTextVisible(true);       
        cytographer.setNodeSize(NODESIZE, true);    
>>>>>>> bbb3f6b
        
        return cytographer;     
    }

我不是在判断哪个结果更好,而是判断哪个结果对我实现的算法有效。
谢谢你!
格莱夫

相关问题