setRef() public method

public setRef ( Ref r ) : void
r Ref
return void
Example #1
0
        private void RecvCommands()
        {
            while (true)
            {
                string line;
                try
                {
                    line = pckIn.ReadStringRaw();
                }
                catch (EndOfStreamException)
                {
                    if (commands.isEmpty())
                    {
                        return;
                    }
                    throw;
                }

                if (line == PacketLineIn.END)
                {
                    break;
                }

                if (commands.isEmpty())
                {
                    int nul = line.IndexOf('\0');
                    if (nul >= 0)
                    {
                        foreach (string c in line.Substring(nul + 1).Split(' '))
                        {
                            enabledCapabilities.Add(c);
                        }
                        line = line.Slice(0, nul);
                    }
                }

                if (line.Length < 83)
                {
                    string m = "error: invalid protocol: wanted 'old new ref'";
                    sendError(m);
                    throw new PackProtocolException(m);
                }

                ObjectId oldId = ObjectId.FromString(line.Slice(0, 40));
                ObjectId newId = ObjectId.FromString(line.Slice(41, 81));
                string   name  = line.Substring(82);
                var      cmd   = new ReceiveCommand(oldId, newId, name);

                if (name.Equals(Constants.HEAD))
                {
                    cmd.setResult(ReceiveCommand.Result.REJECTED_CURRENT_BRANCH);
                }
                else
                {
                    cmd.setRef(refs.get(cmd.getRefName()));
                }

                commands.Add(cmd);
            }
        }
Example #2
0
        private void RecvCommands()
        {
            while (true)
            {
                string line;
                try
                {
                    line = pckIn.ReadStringRaw();
                }
                catch (EndOfStreamException)
                {
                    if (commands.isEmpty())
                    {
                        return;
                    }
                    throw;
                }

                if (commands.isEmpty())
                {
                    int nul = line.IndexOf('\0');
                    if (nul >= 0)
                    {
                        foreach (string c in line.Substring(nul + 1).Split(' '))
                        {
                            enabledCapabilities.Add(c);
                        }
                        line = line.Slice(0, nul);
                    }
                }

                if (line.Length == 0) break;
                if (line.Length < 83)
                {
                    string m = "error: invalid protocol: wanted 'old new ref'";
                    sendError(m);
                    throw new PackProtocolException(m);
                }

                ObjectId oldId = ObjectId.FromString(line.Slice(0, 40));
                ObjectId newId = ObjectId.FromString(line.Slice(41, 81));
                string name = line.Substring(82);
                var cmd = new ReceiveCommand(oldId, newId, name);
                cmd.setRef(refs[cmd.getRefName()]);
                commands.Add(cmd);
            }
        }